Skip to content
agentgateway has joined the Agentic AI Foundation — Learn more

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

Multiple LLM providers

Verified : Code examples on this page have been automatically tested and verified.
Page as Markdown

Define reusable LLM provider configurations once and reference them across multiple model definitions to avoid duplicating connection and authentication parameters.

Reusable provider configuration

Reuse provider configuration to avoid duplicating connection and authentication parameters across multiple model definitions. Define named provider defaults once in llm.providers[] and reference them from multiple llm.models[] entries with provider.reference. You can set up the shared provider in the UI or in your configuration file.

Tip

Compare provider prefixes, exact names, wildcards, and custom names in Choose how to expose models.

To create the shared provider and the two models in the UI, follow these steps. The steps create the same configuration as the Config file tab.

  1. Set your API key in the OPENAI_API_KEY environment variable. The UI checks that the variable exists when you save.

    export OPENAI_API_KEY='<your-api-key>'
  2. Create a configuration file with an empty llm section, and start agentgateway in the same terminal. Without an llm section, the UI does not show the LLM > Models page.

    cat > config.yaml <<'EOF'
    # yaml-language-server: $schema=https://agentgateway.dev/schema/config
    llm:
      models: []
    EOF
    agentgateway -f config.yaml
  3. Create the shared provider.

    1. Open LLM > Providers, such as http://localhost:15000/ui/llm/providers, and click Add provider.

    2. Enter openai-prod for the Provider name.

    3. Keep OpenAI as the Provider.

    4. For the Provider API key, select Env var, and enter OPENAI_API_KEY.

      Add provider drawer with openai-prod as the provider name, OpenAI selected as the provider, and OPENAI_API_KEY as the environment variable for the provider API key
      Add provider drawer with openai-prod as the provider name, OpenAI selected as the provider, and OPENAI_API_KEY as the environment variable for the provider API key
    5. Click Save provider.

  4. Create the fast model.

    1. Open LLM > Models, and click Add model.
    2. From the Provider dropdown, select openai-prod, which is marked configured.
    3. In the Incoming model match field, replace the default openai-prod/* with fast.
    4. For the Outgoing model, select Explicit, and enter gpt-4o-mini.
    5. Click Save model.
  5. Repeat the previous step for the smart model, with the outgoing model gpt-4o.

The Used by column on the LLM > Providers page lists the models that reference each provider. The UI writes the provider as openai instead of openAI. Agentgateway accepts both values.

Whether the UI can save depends on your storage mode. For more information, see Save changes from the UI.

In this example, smart inherits the upstream API key from llm.providers[] and only changes the model name.

Named providers can hold shared upstream settings you want to reuse, such as authentication, host overrides, path overrides, or other model defaults. Keep the shared values on llm.providers[] and only set per-model differences on llm.models[].

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/.