> ## Documentation Index
> Fetch the complete documentation index at: https://docs.octen.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Model Gateway

<p style={{ fontSize: "0.8rem", opacity: 0.6 }}>For AI agents: <a href="https://docs.octen.ai/capabilities/model-gateway.md">docs.octen.ai/capabilities/model-gateway.md</a></p>

Building with LLMs usually means juggling providers, protocols, and API keys, and every model only knows the web as of its training date.

Model Gateway closes both gaps: it serves frontier models from Anthropic, OpenAI, Google, and more behind one API key, with built-in Octen search tools that let any model answer with live web data.

For the full list of parameters, see the [Model Gateway API reference](/api-reference/chat-completions).

## Why Model Gateway

* **One key, frontier lineup.** Claude, GPT, Gemini, and more. Switch models by changing one string.
* **Built-in search.** Enable the built-in search tools and the model grounds its answers on the live web; Octen runs the searches server-side, with no tool plumbing on your side.
* **Drop-in compatibility.** Speaks the OpenAI Chat Completions and Anthropic Messages protocols. Point your existing SDK at the Octen base URL.
* **Image generation.** Create or edit images with image models through the same gateway.

## How It Works

1. Point your existing OpenAI or Anthropic SDK at the Octen base URL and pick a model.
2. Octen routes the request to the model provider; when built-in search tools are enabled, the model decides when to search and Octen executes the searches server-side.
3. The response comes back in the standard protocol shape, grounded in live web results when search was used.

## Scenarios

### Bring your existing code

If your app already uses the OpenAI or Anthropic SDK, switch to Octen by changing the base URL and API key. The rest of your code stays the same.

<CodeGroup>
  ```python OpenAI SDK theme={null}
  from openai import OpenAI

  client = OpenAI(
      api_key="YOUR_OCTEN_API_KEY",
      base_url="https://api.octen.ai/v1",
  )

  response = client.chat.completions.create(
      model="openai/gpt-5.4",
      messages=[{"role": "user", "content": "Explain vector search in one paragraph"}],
  )
  ```

  ```python Anthropic SDK theme={null}
  import anthropic

  client = anthropic.Anthropic(
      api_key="YOUR_OCTEN_API_KEY",
      base_url="https://api.octen.ai",
  )

  response = client.messages.create(
      model="anthropic/claude-sonnet-4.6",
      max_tokens=1024,
      messages=[{"role": "user", "content": "Explain vector search in one paragraph"}],
  )
  ```
</CodeGroup>

### Chat with a frontier model

Call any model in the lineup through the OpenAI Chat Completions protocol.

```bash theme={null}
curl -X POST https://api.octen.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "model": "anthropic/claude-sonnet-4.6",
    "messages": [{ "role": "user", "content": "Explain vector search in one paragraph" }]
  }'
```

### Answer with live web data

Enable a built-in search tool; the model searches when it needs fresh information.

```json theme={null}
{
  "model": "openai/gpt-5.4",
  "messages": [{ "role": "user", "content": "What happened in tech today?" }],
  "tools": [{ "type": "octen_search" }]
}
```

Use `octen_broad_search` instead for multi-angle questions.

### Generate images

Create images from text at `/v1/images/generations`, following the OpenAI Images protocol; pass an input image to edit it instead.

```json theme={null}
{
  "model": "openai/gpt-image-2",
  "prompt": "an isometric illustration of a search engine indexing the web"
}
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Try in Console" icon="play" href="https://octen.ai/platform/model">
    Run Model Gateway live in the Octen console.
  </Card>

  <Card title="Model Gateway API Reference" icon="code" href="/api-reference/chat-completions">
    Full request/response schema.
  </Card>
</CardGroup>
