Skip to main content
Prerequisite: Complete the Quickstart to get an access key. All requests go to https://gateway.ngrok.ai.
The AI Gateway works with any SDK or HTTP client that supports OpenAI API or Anthropic Claude API format. If your language or framework isn’t covered in the dedicated guides, you can still use the gateway.

Requirements

For any SDK or client to work with the AI Gateway, it must:
  1. Support the OpenAI API or Anthropic Claude API format
  2. Allow customizing the base URL / endpoint
  3. Send requests with proper authorization headers (for OpenAI API, Authorization; for Anthropic Claude API, x-api-key)

Authentication

Pass your access key (ng-xxxxx-g1-xxxxx) as the API key. The AI Gateway injects upstream provider credentials from your access key configuration.

cURL

For testing or shell scripts:
curl https://gateway.ngrok.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ng-xxxxx-g1-xxxxx" \  # Your access key
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

HTTP request format

Any HTTP client can call the AI Gateway:
POST /v1/chat/completions HTTP/1.1
Host: gateway.ngrok.ai
Content-Type: application/json
Authorization: Bearer ng-xxxxx-g1-xxxxx

{
  "model": "gpt-4o",
  "messages": [
    {"role": "user", "content": "Hello!"}
  ]
}

Using provider prefixes

All clients support routing to specific providers using model prefixes:
# OpenAI
model: "openai:gpt-4o"

# Anthropic
model: "anthropic:claude-3-5-sonnet-latest"

# Self-hosted
model: "ollama:llama3.2"

Supported endpoints

The AI Gateway supports these endpoints:
EndpointAPI FormatDescription
/v1/chat/completionsOpenAIChat completions
/v1/completionsOpenAILegacy completions
/v1/embeddingsOpenAIText embeddings
/v1/modelsOpenAIList available models
/v1/messagesAnthropicMessages

Next steps