For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
OpenAI 互換プロバイダー
任意の 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.provider | Backend host | Backend path |
|---|---|---|---|
| Baseten | Baseten | inference.baseten.co | /v1/chat/completions |
| Cerebras | Cerebras | api.cerebras.ai | /v1/chat/completions |
| Cohere | Cohere | api.cohere.ai | /compatibility/v1/chat/completions |
| DeepInfra | Deepinfra | api.deepinfra.com | /v1/openai/chat/completions |
| DeepSeek | Deepseek | api.deepseek.com | /v1/chat/completions |
| Fireworks AI | Fireworks | api.fireworks.ai | /inference/v1/chat/completions |
| Groq | Groq | api.groq.com | /openai/v1/chat/completions |
| Hugging Face | Huggingface | router.huggingface.co | /v1/chat/completions |
| Meta | Meta | api.meta.ai | /v1/chat/completions |
| Mistral AI | Mistral | api.mistral.ai | /v1/chat/completions |
Gemini API は、リクエスト本文ではなくリクエストパスでモデルを models/{model}:generateContent として指定します。Gemini または Vertex AI SDK を基にしたクライアントはこの形式を直接送信するため、そのクライアントを agentgateway に向ける場合に OpenAI 互換のシムは必要ありません。 | |||
| OpenRouter | Openrouter | openrouter.ai | /api/v1/chat/completions |
| OpenAI | OpenAI | ||
| Together AI | TogetherAI | api.together.xyz | /v1/chat/completions |
| xAI | XAI | api.x.ai | /v1/chat/completions |
プロバイダーがこの一覧にないものの OpenAI Chat Completions API を公開している場合は、汎用エンドポイントテンプレートを使用します。アップストリームが OpenAI API 形式に一致しない場合は、代わりにカスタムプロバイダーを使用します。
始める前に
クイックスタートガイドに従って、Solo Enterprise for agentgateway コントロールプレーンをインストールします。
プロバイダー認証情報をセットアップする
使用するプロバイダーの API キーを含む Secret を作成します。モデルとバックエンドの例は、どちらもこの Secret を参照します。認証情報を作成した後、いずれか 1 つの設定パスを完了します。
プロバイダーの API キーを取得します。Meta では、Meta Model API dashboard でキーを作成します。
API キーを環境変数に保存します。
export MY_API_KEY='<your-api-key>'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 を使用します。タブ内のモデル名は例です。プロバイダーがサポートするモデルを使用してください。
リスナーで LLM serving を有効にします。リスナーは
AgentgatewayModelルート kind を許可する必要があります。次の例では、agentgateway-proxyGateway のhttpリスナーにアタッチします。モデルを作成します。プロバイダーのタブを選択し、そのプロバイダーの 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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を参照してください。ゲートウェイ経由でリクエストを送信します。モデルエンドポイントは
/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 で公開します。タブ内のモデル名は例です。プロバイダーがサポートするモデルを使用してください。
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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 EOFkubectl 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 値をアップストリームホスト名に設定します。 受信トラフィックを 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リクエストを送信してセットアップを確認します。
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." } ] }' | jqcurl "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.sni | TLS を有効にし、SNI 値をアップストリームホスト名に設定します。 |
アップストリームで混在する API 形式やクラスター内バックエンドターゲットが必要な場合は、代わりにカスタムプロバイダーを使用します。すでにガイドがあるセルフホスト型ターゲットでは、専用の Ollama ページと vLLM ページを優先します。