7. Make your first API call

The gateway exposes an OpenAI-compatible chat completions endpoint on your organization's path. If you've used the OpenAI API, this will feel familiar — you only change the base URL and the token.

Endpoint

POST https://ai-gateway.optum.com/{org}/v1/chat/completions
  • Replace {org} with your organization slug (from step 1, e.g. acme-health).
  • Send Authorization: Bearer <access_token> from step 6.
  • The request/response bodies follow the OpenAI chat completions schema.
  • The model value is the provider-prefixed id from your model list (and GET /{org}/v1/models) — e.g. azure/gpt-4.1-mini. The prefix selects the upstream provider, so copy the exact id the console shows.

curl

curl https://ai-gateway.optum.com/acme-health/v1/chat/completions \
  -H "authorization: Bearer $TOKEN" \
  -H "content-type: application/json" \
  -d '{
    "model": "azure/gpt-4.1-mini",
    "messages": [{ "role": "user", "content": "Say hello in one word." }],
    "max_tokens": 20
  }'

A successful response:

{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "model": "gpt-4.1-mini-2025-04-14",
  "choices": [
    { "index": 0, "finish_reason": "stop",
      "message": { "role": "assistant", "content": "Hello" } }
  ],
  "usage": { "prompt_tokens": 12, "completion_tokens": 1, "total_tokens": 13 }
}

Streaming

Set "stream": true to receive the response as Server-Sent Events (data: chunks terminated by data: [DONE]):

curl https://ai-gateway.optum.com/acme-health/v1/chat/completions \
  -H "authorization: Bearer $TOKEN" \
  -H "content-type: application/json" \
  -d '{
    "model": "azure/gpt-4.1-mini",
    "messages": [{ "role": "user", "content": "Count to five." }],
    "stream": true
  }'

OpenAI Python SDK

Point the SDK's base_url at your organization path and pass the token as the API key:

from openai import OpenAI

client = OpenAI(
    base_url="https://ai-gateway.optum.com/acme-health/v1",
    api_key=TOKEN,  # the bearer access_token from step 6
)

resp = client.chat.completions.create(
    model="azure/gpt-4.1-mini",
    messages=[{"role": "user", "content": "Say hello in one word."}],
)
print(resp.choices[0].message.content)

Common errors

StatusMeaningFix
401 UnauthorizedNo token, or an expired / malformed token.Send Authorization: Bearer <token>; refresh if expired (step 6).
403 ForbiddenThe token is valid but its client isn't authorized for this organization.Confirm you're calling your own org's {org} path and that the credential belongs to that org (step 5).
500 "failed to get balancer instance"The requested model isn't enabled on this organization's route.Enable the model and Publish (step 4), or send a model that's enabled.
404 Not found (HTML)The path or org slug is wrong.Check the base URL and {org} slug.

That's the full path — you now have a working, authenticated chat completion through the AI Gateway.