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.

Custom

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

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: support 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.

Note

Many providers provide “OpenAI compatible” or “Anthropic compatible” endpoints. While these can be used with provider: openai/provider: anthropic and a customized baseUrl, prefer to use provider: custom.

Using a specific vendor’s provider may introduce semantics specific to that provider.

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.

Configuring a custom provider

With a custom provider, you provide the API endpoint and a list of formats it supports. Agentgateway will automatically handle mapping between the incoming format and the supported formats.

The formats list decides which conversion an incoming request takes, and the conversions do not all carry the same feature set. A provider that declares completions carries extended-thinking history across turns, while one that declares responses and not completions drops it without an error. For what each conversion keeps and drops, see Provider format conversion.

The formats list is optional. A model without it accepts only requests on paths that are forwarded to the provider without format conversion, such as /v1/systemone, /v1/ocr, /v1/images/generations, and /v1/responses/compact. A request in an LLM API format, such as a chat completions or messages request, has no format to convert to and is rejected. For an example, see the Jev guardrail guide.

Below shows an example of connecting to Perplexity, which exposes an OpenAI-compatible API for search-augmented models and does not currently have a first-class provider.

cat > /tmp/test-perplexity.yaml << 'EOF'
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
llm:
  models:
  - name: "*"
    provider:
      custom:
        formats:
          # Indicate this provider supports the completions API. With no `path` specified, this defaults to <baseUrl>/chat/completions
          - type: completions
          # Indicate this provider supports the messages API, on a custom path /messages-api
          # - type: messages
          #   path: /messages-api
          # All possible APIs:
          # - type: embeddings
          # - type: responses
          # - type: realtime
          # - type: anthropicTokenCount
          # - type: generateContent
          # - type: geminiCountTokens
          # - type: rerank
    params:
      apiKey: "$PERPLEXITY_API_KEY"
      model: llama-3.1-sonar-large-128k-online
      baseUrl: "https://api.perplexity.ai"
EOF
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/.