コンテンツにスキップ
これは最新の機能を備えた最新リリースですが、長期サポートは提供されません。サポートを継続するには、新しいリリースごとにアップグレードするか、四半期ごとの安定版リリースをご利用ください。

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

OpenAI 互換プロバイダー

Page as Markdown

任意の OpenAI 互換 LLM プロバイダーの設定とセットアップ。

AgentgatewayModel または EnterpriseAgentgatewayBackend リソースを使用して、OpenAI 互換 LLM プロバイダーを設定します。

概要

リクエストをどのようにルーティングするかに合うリソースを選択します。どちらの方法でも、このページで作成するプロバイダー認証情報を使用します。

リソース使用するタイミング
AgentgatewayModelリクエスト内のモデル名でルーティングし、/v1/chat/completions などの標準 LLM パスを提供します。プロバイダープリセットは、デフォルト URL とサポートされるリクエスト形式を提供します。
AgentgatewayBackend と HTTPRouteパス、ヘッダー、またはその他の HTTPRoute match によってルーティングを設定します。このページのプロバイダーでは、spec.ai.provider.openai を設定し、アップストリームのホストとパスを設定します。

AgentgatewayModel API は agentgateway 1.6 でデフォルトで有効になっています。2 つの方法の詳細については、モデルについてを参照してください。

組み込みの OpenAI 互換プロバイダー

AgentgatewayModel では、表にある大文字と小文字を区別する spec.provider 値を使用します。spec.baseURL を省略すると、プリセットのデフォルト URL が使用されます。EnterpriseAgentgatewayBackend では、port: 443 とともに host 列と path 列を使用します。

プロバイダーモデルの spec.providerBackend hostBackend path
BasetenBaseteninference.baseten.co/v1/chat/completions
CerebrasCerebrasapi.cerebras.ai/v1/chat/completions
CohereCohereapi.cohere.ai/compatibility/v1/chat/completions
DeepInfraDeepinfraapi.deepinfra.com/v1/openai/chat/completions
DeepSeekDeepseekapi.deepseek.com/v1/chat/completions
Fireworks AIFireworksapi.fireworks.ai/inference/v1/chat/completions
GroqGroqapi.groq.com/openai/v1/chat/completions
Hugging FaceHuggingfacerouter.huggingface.co/v1/chat/completions
MetaMetaapi.meta.ai/v1/chat/completions
Mistral AIMistralapi.mistral.ai/v1/chat/completions
Gemini API は、リクエスト本文ではなくリクエストパスでモデルを models/{model}:generateContent として指定します。Gemini または Vertex AI SDK を基にしたクライアントはこの形式を直接送信するため、そのクライアントを agentgateway に向ける場合に OpenAI 互換のシムは必要ありません。
OpenRouterOpenrouteropenrouter.ai/api/v1/chat/completions
OpenAIOpenAI
Together AITogetherAIapi.together.xyz/v1/chat/completions
xAIXAIapi.x.ai/v1/chat/completions

プロバイダーがこの一覧にないものの OpenAI Chat Completions API を公開している場合は、汎用エンドポイントテンプレートを使用します。アップストリームが OpenAI API 形式に一致しない場合は、代わりにカスタムプロバイダーを使用します。

始める前に

クイックスタートガイドに従って、Solo Enterprise for agentgateway コントロールプレーンをインストールします。

プロバイダー認証情報をセットアップする

使用するプロバイダーの API キーを含む Secret を作成します。モデルとバックエンドの例は、どちらもこの Secret を参照します。認証情報を作成した後、いずれか 1 つの設定パスを完了します。

  1. プロバイダーの API キーを取得します。Meta では、Meta Model API dashboard でキーを作成します。

  2. API キーを環境変数に保存します。

    export MY_API_KEY='<your-api-key>'
  3. API キーを保存する Kubernetes シークレットを作成します。

    kubectl apply -f- <<EOF
    apiVersion: v1
    kind: Secret
    metadata:
      name: llm-provider-secret
      namespace: agentgateway-system
    type: Opaque
    stringData:
      Authorization: $MY_API_KEY
    EOF

AgentgatewayModel を設定する

プロバイダープリセットを使用して、ゲートウェイ経由で標準 LLM API を提供します。各例では、プロバイダーのデフォルト URL と前のセクションの Secret を使用します。タブ内のモデル名は例です。プロバイダーがサポートするモデルを使用してください。

  1. リスナーで LLM serving を有効にします。リスナーは AgentgatewayModel ルート kind を許可する必要があります。次の例では、agentgateway-proxy Gateway の http リスナーにアタッチします。

  2. モデルを作成します。プロバイダーのタブを選択し、そのプロバイダーの API キーを Secret で使用します。提供するモデルを spec.match.model に設定します。

    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayModel
    metadata:
      name: llm-model
      namespace: agentgateway-system
    spec:
      parentRefs:
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: agentgateway-proxy
        sectionName: http
      match:
        model: meta-llama/Llama-3.1-8B-Instruct
      provider: Baseten
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
    EOF
    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayModel
    metadata:
      name: llm-model
      namespace: agentgateway-system
    spec:
      parentRefs:
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: agentgateway-proxy
        sectionName: http
      match:
        model: llama-3.3-70b
      provider: Cerebras
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
    EOF
    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayModel
    metadata:
      name: llm-model
      namespace: agentgateway-system
    spec:
      parentRefs:
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: agentgateway-proxy
        sectionName: http
      match:
        model: command-r-plus
      provider: Cohere
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
    EOF
    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayModel
    metadata:
      name: llm-model
      namespace: agentgateway-system
    spec:
      parentRefs:
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: agentgateway-proxy
        sectionName: http
      match:
        model: meta-llama/Meta-Llama-3.1-8B-Instruct
      provider: Deepinfra
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
    EOF
    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayModel
    metadata:
      name: llm-model
      namespace: agentgateway-system
    spec:
      parentRefs:
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: agentgateway-proxy
        sectionName: http
      match:
        model: deepseek-chat
      provider: Deepseek
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
    EOF
    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayModel
    metadata:
      name: llm-model
      namespace: agentgateway-system
    spec:
      parentRefs:
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: agentgateway-proxy
        sectionName: http
      match:
        model: accounts/fireworks/models/llama-v3p1-70b-instruct
      provider: Fireworks
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
    EOF
    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayModel
    metadata:
      name: llm-model
      namespace: agentgateway-system
    spec:
      parentRefs:
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: agentgateway-proxy
        sectionName: http
      match:
        model: llama-3.3-70b-versatile
      provider: Groq
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
    EOF
    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayModel
    metadata:
      name: llm-model
      namespace: agentgateway-system
    spec:
      parentRefs:
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: agentgateway-proxy
        sectionName: http
      match:
        model: meta-llama/Llama-3.1-8B-Instruct
      provider: Huggingface
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
    EOF
    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayModel
    metadata:
      name: llm-model
      namespace: agentgateway-system
    spec:
      parentRefs:
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: agentgateway-proxy
        sectionName: http
      match:
        model: muse-spark-1.3
      provider: Meta
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
    EOF
    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayModel
    metadata:
      name: llm-model
      namespace: agentgateway-system
    spec:
      parentRefs:
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: agentgateway-proxy
        sectionName: http
      match:
        model: mistral-large-latest
      provider: Mistral
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
    EOF
    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayModel
    metadata:
      name: llm-model
      namespace: agentgateway-system
    spec:
      parentRefs:
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: agentgateway-proxy
        sectionName: http
      match:
        model: openai/gpt-4o
      provider: Openrouter
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
    EOF
    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayModel
    metadata:
      name: llm-model
      namespace: agentgateway-system
    spec:
      parentRefs:
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: agentgateway-proxy
        sectionName: http
      match:
        model: meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo
      provider: TogetherAI
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
    EOF
    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayModel
    metadata:
      name: llm-model
      namespace: agentgateway-system
    spec:
      parentRefs:
      - group: gateway.networking.k8s.io
        kind: Gateway
        name: agentgateway-proxy
        sectionName: http
      match:
        model: grok-2-latest
      provider: XAI
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
    EOF
    設定説明
    spec.parentRefs同じ namespace 内の agentgateway-proxy の http リスナーにモデルをアタッチします。このリスナーは、別のバックエンドや HTTPRoute なしでモデルを提供します。
    spec.match.modelクライアントがリクエストで送信するモデル名です。各例では、同じ名前をプロバイダーに転送します。
    spec.providerMeta や Groq などのプロバイダープリセットです。プリセットは URL とリクエスト形式を提供します。
    spec.policies.auth.secretRef.nameAuthorization エントリにプロバイダー API キーを含む Secret です。Secret はモデルと同じ namespace 内にある必要があります。

    プリセットの URL を上書きするには、spec.baseURL を設定します。URL 形式と例については、Providersを参照してください。

  3. ゲートウェイ経由でリクエストを送信します。モデルエンドポイントは /v1/chat/completions です。<your-model> を、モデル設定の spec.match.model 値に置き換えます。

    curl "http://$INGRESS_GW_ADDRESS/v1/chat/completions" \
      -H 'Content-Type: application/json' \
      -d '{
        "model": "<your-model>",
        "messages": [{"role": "user", "content": "Explain retrieval-augmented generation in one sentence."}]
      }' | jq

    リスナーセットアップガイドの port-forward を使用します。

    curl http://localhost:8080/v1/chat/completions \
      -H 'Content-Type: application/json' \
      -d '{
        "model": "<your-model>",
        "messages": [{"role": "user", "content": "Explain retrieval-augmented generation in one sentence."}]
      }' | jq

AgentgatewayBackend を設定する

この方法を使用して、HTTPRoute でバックエンドを選択します。例では spec.ai.provider.openai 経由で Chat Completions を設定し、バックエンドを /llm で公開します。タブ内のモデル名は例です。プロバイダーがサポートするモデルを使用してください。

  1. openai プロバイダーをプロバイダーのホストとパスに向ける EnterpriseAgentgatewayBackend リソースを作成します。プロバイダーのタブを選択します。

    kubectl apply -f- <<EOF
    apiVersion: enterpriseagentgateway.solo.io/v1alpha1
    kind: EnterpriseAgentgatewayBackend
    metadata:
      name: llm-backend
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          openai:
            model: meta-llama/Llama-3.1-8B-Instruct
          host: inference.baseten.co
          port: 443
          path: /v1/chat/completions
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
        tls:
          sni: inference.baseten.co
    EOF
    kubectl apply -f- <<EOF
    apiVersion: enterpriseagentgateway.solo.io/v1alpha1
    kind: EnterpriseAgentgatewayBackend
    metadata:
      name: llm-backend
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          openai:
            model: llama-3.3-70b
          host: api.cerebras.ai
          port: 443
          path: /v1/chat/completions
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
        tls:
          sni: api.cerebras.ai
    EOF
    kubectl apply -f- <<EOF
    apiVersion: enterpriseagentgateway.solo.io/v1alpha1
    kind: EnterpriseAgentgatewayBackend
    metadata:
      name: llm-backend
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          openai:
            model: command-r-plus
          host: api.cohere.ai
          port: 443
          path: /compatibility/v1/chat/completions
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
        tls:
          sni: api.cohere.ai
    EOF
    kubectl apply -f- <<EOF
    apiVersion: enterpriseagentgateway.solo.io/v1alpha1
    kind: EnterpriseAgentgatewayBackend
    metadata:
      name: llm-backend
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          openai:
            model: meta-llama/Meta-Llama-3.1-8B-Instruct
          host: api.deepinfra.com
          port: 443
          path: /v1/openai/chat/completions
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
        tls:
          sni: api.deepinfra.com
    EOF
    kubectl apply -f- <<EOF
    apiVersion: enterpriseagentgateway.solo.io/v1alpha1
    kind: EnterpriseAgentgatewayBackend
    metadata:
      name: llm-backend
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          openai:
            model: deepseek-chat
          host: api.deepseek.com
          port: 443
          path: /v1/chat/completions
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
        tls:
          sni: api.deepseek.com
    EOF
    kubectl apply -f- <<EOF
    apiVersion: enterpriseagentgateway.solo.io/v1alpha1
    kind: EnterpriseAgentgatewayBackend
    metadata:
      name: llm-backend
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          openai:
            model: accounts/fireworks/models/llama-v3p1-70b-instruct
          host: api.fireworks.ai
          port: 443
          path: /inference/v1/chat/completions
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
        tls:
          sni: api.fireworks.ai
    EOF
    kubectl apply -f- <<EOF
    apiVersion: enterpriseagentgateway.solo.io/v1alpha1
    kind: EnterpriseAgentgatewayBackend
    metadata:
      name: llm-backend
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          openai:
            model: llama-3.3-70b-versatile
          host: api.groq.com
          port: 443
          path: /openai/v1/chat/completions
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
        tls:
          sni: api.groq.com
    EOF
    kubectl apply -f- <<EOF
    apiVersion: enterpriseagentgateway.solo.io/v1alpha1
    kind: EnterpriseAgentgatewayBackend
    metadata:
      name: llm-backend
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          openai:
            model: meta-llama/Llama-3.1-8B-Instruct
          host: router.huggingface.co
          port: 443
          path: /v1/chat/completions
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
        tls:
          sni: router.huggingface.co
    EOF
    kubectl apply -f- <<EOF
    apiVersion: enterpriseagentgateway.solo.io/v1alpha1
    kind: EnterpriseAgentgatewayBackend
    metadata:
      name: llm-backend
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          openai:
            model: muse-spark-1.3
          host: api.meta.ai
          port: 443
          path: /v1/chat/completions
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
        tls:
          sni: api.meta.ai
    EOF
    kubectl apply -f- <<EOF
    apiVersion: enterpriseagentgateway.solo.io/v1alpha1
    kind: EnterpriseAgentgatewayBackend
    metadata:
      name: llm-backend
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          openai:
            model: mistral-large-latest
          host: api.mistral.ai
          port: 443
          path: /v1/chat/completions
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
        tls:
          sni: api.mistral.ai
    EOF
    kubectl apply -f- <<EOF
    apiVersion: enterpriseagentgateway.solo.io/v1alpha1
    kind: EnterpriseAgentgatewayBackend
    metadata:
      name: llm-backend
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          openai:
            model: openai/gpt-4o
          host: openrouter.ai
          port: 443
          path: /api/v1/chat/completions
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
        tls:
          sni: openrouter.ai
    EOF
    kubectl apply -f- <<EOF
    apiVersion: enterpriseagentgateway.solo.io/v1alpha1
    kind: EnterpriseAgentgatewayBackend
    metadata:
      name: llm-backend
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          openai:
            model: meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo
          host: api.together.xyz
          port: 443
          path: /v1/chat/completions
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
        tls:
          sni: api.together.xyz
    EOF
    kubectl apply -f- <<EOF
    apiVersion: enterpriseagentgateway.solo.io/v1alpha1
    kind: EnterpriseAgentgatewayBackend
    metadata:
      name: llm-backend
      namespace: agentgateway-system
    spec:
      ai:
        provider:
          openai:
            model: grok-2-latest
          host: api.x.ai
          port: 443
          path: /v1/chat/completions
      policies:
        auth:
          secretRef:
            name: llm-provider-secret
        tls:
          sni: api.x.ai
    EOF

    この設定を理解するために、次の表を確認します。

    設定説明
    ai.provider.openai.model省略可能なアップストリームモデルの上書き。クライアントが指定したモデルをそのまま渡すには、このパラメーターを省略します。
    host と portプロバイダーの API ホストとポート。HTTPS エンドポイントには 443 を使用します。
    pathプロバイダーのチャット補完パス。標準の /v1/chat/completions パスを使用するプロバイダーでも path を設定します。path や pathPrefix を指定せずに host を設定すると、プロバイダーは次の手順の HTTPRoute の /llm など、クライアントのリクエストパスをそのまま受け取ります。
    policies.auth.secretRefプロバイダー API キーを含むシークレットを参照します。
    policies.tls.sniTLS を有効にし、SNI 値をアップストリームホスト名に設定します。
  2. 受信トラフィックを EnterpriseAgentgatewayBackend にルーティングする HTTPRoute リソースを作成します。

    kubectl apply -f- <<EOF
    apiVersion: gateway.networking.k8s.io/v1
    kind: HTTPRoute
    metadata:
      name: llm-route
      namespace: agentgateway-system
    spec:
      parentRefs:
        - name: agentgateway-proxy
          namespace: agentgateway-system
      rules:
      - matches:
        - path:
            type: PathPrefix
            value: /llm
        backendRefs:
        - name: llm-backend
          namespace: agentgateway-system
          group: enterpriseagentgateway.solo.io
          kind: EnterpriseAgentgatewayBackend
    EOF
  3. リクエストを送信してセットアップを確認します。model の値を、EnterpriseAgentgatewayBackend に設定したモデルに置き換えます。

    curl "$INGRESS_GW_ADDRESS/llm" -H content-type:application/json -d '{
       "model": "<your-model>",
       "messages": [
         {
           "role": "user",
           "content": "Explain retrieval-augmented generation in one sentence."
         }
       ]
     }' | jq
    curl "localhost:8080/llm" -H content-type:application/json -d '{
       "model": "<your-model>",
       "messages": [
         {
           "role": "user",
           "content": "Explain retrieval-augmented generation in one sentence."
         }
       ]
     }' | jq

その他の OpenAI 互換プロバイダー

| Gemini | Google AI pricing |

汎用 OpenAI 互換エンドポイント

プロバイダーが OpenAI Chat Completions API を公開しているものの、組み込みの OpenAI 互換プロバイダー表にない場合は、このテンプレートを使用します。

apiVersion: enterpriseagentgateway.solo.io/v1alpha1
kind: EnterpriseAgentgatewayBackend
metadata:
  name: generic-openai
  namespace: agentgateway-system
spec:
  ai:
    provider:
      openai:
        model: <upstream-model-name>
      host: api.example.com
      port: 443
      path: /v1/chat/completions
  policies:
    auth:
      secretRef:
        name: provider-secret
    tls:
      sni: api.example.com

テンプレートを調整するには、次のフィールドを使用します。

設定説明
ai.provider.openai.model省略可能なアップストリームモデルの上書き。クライアントが指定したモデルをそのまま渡すには、このパラメーターを省略します。
host と port外部プロバイダーエンドポイントの必須ターゲットアドレス。
pathプロバイダーのチャット補完パス。標準の /v1/chat/completions パスでも、このパラメーターを設定します。path や pathPrefix を指定せずに host を設定すると、プロバイダーはクライアントのリクエストパスをそのまま受け取ります。Chat Completions リクエストを /v1/chat/completions に、Responses リクエストを /v1/responses に送る場合など、各リクエスト形式をそれぞれのパスに送信するには、path ではなく pathPrefix: /v1 を設定します。
policies.authプロバイダー API キーシークレットを送信リクエストにアタッチします。
policies.tls.sniTLS を有効にし、SNI 値をアップストリームホスト名に設定します。

アップストリームで混在する API 形式やクラスター内バックエンドターゲットが必要な場合は、代わりにカスタムプロバイダーを使用します。すでにガイドがあるセルフホスト型ターゲットでは、専用の Ollama ページと vLLM ページを優先します。

次のステップ