Skip to main content

GET /v1/models

Returns a list of models available through the gateway. This endpoint can return models from the control plane or pass through to the configured provider.

Authentication

Requires API key authentication:
x-portkey-api-key: YOUR_API_KEY
# OR
Authorization: Bearer YOUR_API_KEY

Request

Headers

x-portkey-api-key
string
Your Portkey API key (alternative to Authorization header)
Authorization
string
Bearer token authentication
x-portkey-provider
string
Optional provider to list models from (e.g., openai, anthropic)
x-portkey-virtual-key
string
Optional virtual key to use for authentication

Query Parameters

Query parameters are passed through to the provider or control plane.

Response

object
string
The object type, always “list”
data
array
Array of model objects

Example

curl https://localhost:8787/v1/models \
  -H "x-portkey-api-key: YOUR_API_KEY"

Response Example

{
  "object": "list",
  "data": [
    {
      "id": "gpt-4o",
      "object": "model",
      "created": 1687882411,
      "owned_by": "openai"
    },
    {
      "id": "gpt-4o-mini",
      "object": "model",
      "created": 1687882411,
      "owned_by": "openai"
    },
    {
      "id": "claude-3-5-sonnet-20241022",
      "object": "model",
      "created": 1687882411,
      "owned_by": "anthropic"
    }
  ]
}

Behavior

The endpoint behavior depends on configuration:

With Provider Header

When you specify x-portkey-provider, the request is forwarded to that provider’s models endpoint:
curl https://localhost:8787/v1/models \
  -H "x-portkey-provider: openai" \
  -H "Authorization: Bearer sk-..."
This returns models available from OpenAI.

Without Provider Header

When no provider is specified and a control plane URL is configured, the gateway returns models from the Portkey control plane, which aggregates models across all configured providers.

Use Cases

Query available models to dynamically select the best model for your use case based on capabilities, pricing, or performance.
List models from a specific provider to understand what’s available before making requests.
Check if a specific model ID is available before attempting to use it.

Chat Completions

Use a model for chat completions

Completions

Use a model for completions

Embeddings

Use a model for embeddings

Build docs developers (and LLMs) love