Skip to content
🎯 New workshop: Govern AI Costs in Real Time — Hands-On with agentgateway agentgateway has joined the Agentic AI FoundationLearn more

For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.

Page as Markdown

OpenAI-compatible providers

Verified Code examples on this page have been automatically tested and verified.

Configure agentgateway for providers without built-in support that implement the OpenAI API format.

Use this page for providers that implement the OpenAI API format but do not have a first-class provider: shortcut yet. For built-in providers such as Baseten, Cerebras, Cohere, DeepInfra, DeepSeek, Fireworks AI, Groq, Hugging Face, Mistral, OpenRouter, Together AI, xAI, and Ollama, use the dedicated provider pages instead.

If you need a different upstream endpoint for one of those built-in standalone providers, keep the first-class provider: value and set params.baseUrl on that provider instead of switching to provider: openAI.

In standalone mode, configure upstream authentication per model with llm.models[].auth and upstream TLS with llm.models[].tls. For an overview of the available auth and TLS options, see Providers.

Before you begin

Install the agentgateway binary.

You also need the following prerequisites.

  • An API key for your chosen provider, unless you are pointing to a local endpoint such as vLLM or LM Studio.

Managed provider fallback

Perplexity

Perplexity exposes an OpenAI-compatible API for search-augmented models and does not currently have a first-class standalone provider shortcut.

cat > /tmp/test-perplexity.yaml << 'EOF'
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
llm:
  port: 3000
  models:
  - name: "*"
    provider: openAI
    auth:
      key:
        value: "$PERPLEXITY_API_KEY"
    params:
      model: llama-3.1-sonar-large-128k-online
      baseUrl: "https://api.perplexity.ai"
    tls: {}
EOF

Self-hosted OpenAI-compatible endpoints

vLLM

vLLM is a high-performance model server for self-hosted OpenAI-compatible inference.

cat > /tmp/test-vllm.yaml << 'EOF'
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
llm:
  port: 3000
  models:
  - name: "*"
    provider: openAI
    params:
      baseUrl: "http://localhost:8000/v1"
EOF

If your vLLM server uses HTTPS, set params.baseUrl to the HTTPS endpoint and add tls: {} to the model configuration. (In agentgateway versions prior to 1.3, this model-level setting was called backendTLS.)

LM Studio

LM Studio runs models locally and exposes an OpenAI-compatible API for desktop testing.

cat > /tmp/test-lmstudio.yaml << 'EOF'
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
llm:
  port: 3000
  models:
  - name: llama-3.2-90b
    provider: openAI
    params:
      baseUrl: "http://localhost:1234/v1"
EOF

Enable the local server in LM Studio: Settings > Local Server > Start Server.

Generic configuration

Use the following template for any OpenAI-compatible provider without built-in support:

llm:
  port: 3000
  models:
  - name: "*"
    provider: openAI
    auth:
      key:
        value: "$PROVIDER_API_KEY"
    params:
      model: "<upstream-model-name>"
      baseUrl: "https://provider.example.com/v1"
    tls: {}  # only for HTTPS providers

Set params.baseUrl to the provider’s API root. This can include provider-specific prefixes such as /v1, /openai/v1, or another base path. If the provider already has a first-class page, use that provider shortcut and its documented default base URL instead.

FieldDescription
providerSet to openAI for OpenAI-compatible providers without a first-class shortcut.
auth.key.valueOptional. The API key for the provider. Reference environment variables with the $VAR_NAME syntax. Omit for local endpoints that do not require authentication.
params.modelOptional. Override the upstream model name. Omit to pass the client-provided model through.
params.baseUrlThe provider’s API root URL, including scheme and any required base path prefix.
tlsEnable TLS for the upstream connection. Required for HTTPS providers, omit for local HTTP providers. (In agentgateway versions prior to 1.3, this model-level setting was called backendTLS.)
Was this page helpful?
Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.