For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
Model aliasing
Configure global or provider-specific model aliases to reference models by user-friendly names.
Configure global or provider-specific aliases for your models to refer to your model by using user-friendly names.
Note
Model-centric alternative: The experimental AgentgatewayModel API aliases models by design, so it has no modelAliases field. Each resource publishes a client-facing name and rewrites it to the provider’s name with a model transformation. For more information, see About models.
Before you begin
Set up aliases
Update your AgentgatewayBackend to add global model aliases. The following example adds two aliases,
fastandsmart. Each alias points to a specific model. Note that the example does not specify a default model.kubectl apply -f- <<EOF apiVersion: agentgateway.dev/v1alpha1 kind: AgentgatewayBackend metadata: name: openai namespace: agentgateway-system spec: ai: provider: openai: {} policies: auth: secretRef: name: openai-secret ai: modelAliases: fast: gpt-3.5-turbo smart: gpt-4-turbo EOFSend a request to the OpenAI provider with the
fastmodel. Verify that the request succeeds and that you also see thegpt-3.5-turbomodel in your response.Cloud Provider LoadBalancer:
curl "$INGRESS_GW_ADDRESS/v1/chat/completions" -H content-type:application/json -d '{ "model": "fast", "messages": [ { "role": "system", "content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair." }, { "role": "user", "content": "Compose a poem that explains the concept of recursion in programming." } ] }' | jqLocalhost:
curl "localhost:8080/v1/chat/completions" -H content-type:application/json -d '{ "model": "fast", "messages": [ { "role": "system", "content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair." }, { "role": "user", "content": "Compose a poem that explains the concept of recursion in programming." } ] }' | jqExample output:
{ "model": "gpt-3.5-turbo-0125", "usage": { "prompt_tokens": 39, ...Repeat the request to the OpenAI provider with the
smartmodel. Verify that the request succeeds and that you also see thegpt-4-turbomodel in your response.Cloud Provider LoadBalancer:
curl "$INGRESS_GW_ADDRESS/v1/chat/completions" -H content-type:application/json -d '{ "model": "smart", "messages": [ { "role": "system", "content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair." }, { "role": "user", "content": "Compose a poem that explains the concept of recursion in programming." } ] }' | jqLocalhost:
curl "localhost:8080/v1/chat/completions" -H content-type:application/json -d '{ "model": "smart", "messages": [ { "role": "system", "content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair." }, { "role": "user", "content": "Compose a poem that explains the concept of recursion in programming." } ] }' | jqExample output:
{ "model": "gpt-4-turbo-2024-04-09", "usage": { "prompt_tokens": 39, ...
Cleanup
You can remove the resources that you created in this guide.
kubectl delete AgentgatewayBackend openai -n agentgateway-system