> ## Documentation Index
> Fetch the complete documentation index at: https://portkey-docs-docs-prisma-airs-updates.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> One OpenAI-compatible endpoint in front of every model you have connected

The Gateway API runs inference. The [Admin API](/aigw/api-reference/admin-api/introduction) configures what it is allowed to do.

Point an OpenAI-compatible client at the gateway, name a model, and the request is routed, guarded, logged and billed according to the configuration your administrators have already put in place. Nothing about routing, credentials or policy belongs in the request itself.

```sh theme={"system"}
curl https://aigw.portkey.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "@openai-prod/gpt-4o",
    "messages": [
      { "role": "user", "content": "Hello!" }
    ]
  }'
```

Two things carry the routing: the `Authorization` header holds your gateway API key, and the `model` field is prefixed with the slug of the integration to use. `@openai-prod/gpt-4o` reads as *the `gpt-4o` model, through the integration called `openai-prod`*.

<Info>
  The base URL is `https://aigw.portkey.ai/v1`. MCP Gateway serves `/m` and Agent Gateway serves `/agent`.
</Info>

## Two ways in

<CardGroup cols={2}>
  <Card title="An OpenAI-compatible SDK" icon="code">
    Change the base URL and the API key on a client you already have. This is also how Langchain, LlamaIndex and most agent frameworks connect.
  </Card>

  <Card title="REST" icon="terminal">
    Call the endpoints directly. Everything the SDKs do is available over plain HTTP.
  </Card>
</CardGroup>

### Through an OpenAI SDK

Install the official client, then override two fields:

<CodeGroup>
  ```python Python theme={"system"}
  from openai import OpenAI

  client = OpenAI(
      api_key="PORTKEY_API_KEY",
      base_url="https://aigw.portkey.ai/v1",
  )

  response = client.chat.completions.create(
      model="@openai-prod/gpt-4o",
      messages=[{"role": "user", "content": "Say this is a test"}],
  )
  ```

  ```js NodeJS theme={"system"}
  import OpenAI from 'openai';

  const client = new OpenAI({
    apiKey: "PORTKEY_API_KEY",
    baseURL: "https://aigw.portkey.ai/v1",
  });

  const response = await client.chat.completions.create({
    model: '@openai-prod/gpt-4o',
    messages: [{ role: 'user', content: 'Say this is a test' }],
  });
  ```
</CodeGroup>

Gateway-specific behaviour (a saved config, request metadata, a cache directive) travels in headers, which the SDKs expose as `default_headers` / `defaultHeaders`.

## Start here

<CardGroup cols={2}>
  <Card title="Authentication" icon="key" href="/aigw/api-reference/inference-api/authentication">
    API keys, and JWT as an alternative
  </Card>

  <Card title="Headers" icon="list" href="/aigw/api-reference/inference-api/headers">
    Every gateway header, and what each one changes
  </Card>

  <Card title="Config object" icon="sliders" href="/aigw/api-reference/inference-api/config-object">
    Routing, fallbacks, retries and caching as a single object
  </Card>

  <Card title="Supported providers" icon="plug" href="/aigw/api-reference/inference-api/supported-providers">
    What can sit behind the gateway
  </Card>

  <Card title="Response schema" icon="brackets-curly" href="/aigw/api-reference/inference-api/response-schema">
    What comes back, and where the gateway adds to it
  </Card>

  <Card title="Error codes" icon="triangle-exclamation" href="/aigw/api-reference/inference-api/error-codes">
    Failures on the inference path
  </Card>
</CardGroup>
