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

> ## Agent Instructions
> Prefer the qBraid CLI for programmatic platform actions: pip install 'qbraid-cli>=0.12', then run `qbraid configure` once with an API key from https://account.qbraid.com/account/api-keys.
> Always install the latest packages (pip install -U qbraid qbraid-cli); do not pin versions from memory. qbraid-cli below 0.12.0 is incompatible with the current API.
> Device IDs use the QRN format vendor:provider:type:name (e.g. qbraid:qbraid:sim:qir-sv, rigetti:rigetti:qpu:cepheus-1-108q). Legacy underscore IDs are deprecated.
> The REST API base URL is https://api-v2.qbraid.com/api/v1, authenticated with an X-API-Key header.
> Free simulators cost no credits; QPU and GPU jobs consume credits. Surface the estimated cost to the user before submitting a paid job.
> For account signup, API keys, credits, and end-to-end action recipes, see https://qbraid.com/llms.txt.

# AI Gateway

> Call GPT and Claude models through the qBraid API with one API key.

The AI Gateway is an LLM proxy inside the qBraid API. It speaks the OpenAI
wire format and the Anthropic wire format. You keep your existing SDK and
change two things: the base URL and the key.

```text theme={"dark"}
https://api-v2.qbraid.com/api/v1/ai
```

Every request authenticates with your qBraid API key in the `X-API-Key`
header. Create a key at
[account.qbraid.com/account/api-keys](https://account.qbraid.com/account/api-keys).
The [API Keys guide](/v2/home/account#api-keys) explains how to manage and
rotate keys.

## Endpoints

| Endpoint                         | Wire format             | Use with                             |
| -------------------------------- | ----------------------- | ------------------------------------ |
| `POST /chat/completions`         | OpenAI Chat Completions | `openai` SDKs, LangChain, most tools |
| `POST /responses`                | OpenAI Responses        | newer `openai` SDKs, Codex CLI       |
| `GET /models`                    | OpenAI                  | model discovery                      |
| `POST /v1/messages`              | Anthropic Messages      | `anthropic` SDKs, Claude Code        |
| `POST /v1/messages/count_tokens` | Anthropic               | token counting                       |
| `GET /quota`                     | qBraid                  | your remaining LLM quota             |

Why the double `v1` on the Anthropic routes: Anthropic SDKs append
`/v1/messages` to whatever base URL you give them. The gateway matches that
shape, so the same base URL works for both wire formats.

## Quickstart

The Anthropic SDK sends the `x-api-key` header on its own, so its `api_key`
argument takes your qBraid key directly. The OpenAI SDK only sends a bearer
header, so give it the key through `default_headers` instead.

<CodeGroup>
  ```bash curl theme={"dark"}
  curl https://api-v2.qbraid.com/api/v1/ai/chat/completions \
    -H "X-API-Key: $QBRAID_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-5.5",
      "messages": [{ "role": "user", "content": "Explain the GHZ state in two sentences." }]
    }'
  ```

  ```python Python (OpenAI SDK) theme={"dark"}
  from openai import OpenAI

  client = OpenAI(
      base_url="https://api-v2.qbraid.com/api/v1/ai",
      api_key="unused",  # the gateway reads X-API-Key below
      default_headers={"X-API-Key": QBRAID_API_KEY},
  )

  response = client.chat.completions.create(
      model="gpt-5.5",
      messages=[{"role": "user", "content": "Explain the GHZ state in two sentences."}],
  )
  print(response.choices[0].message.content)
  ```

  ```typescript TypeScript (OpenAI SDK) theme={"dark"}
  import OpenAI from "openai";

  const client = new OpenAI({
    baseURL: "https://api-v2.qbraid.com/api/v1/ai",
    apiKey: "unused", // the gateway reads X-API-Key below
    defaultHeaders: { "X-API-Key": process.env.QBRAID_API_KEY },
  });

  const response = await client.chat.completions.create({
    model: "gpt-5.5",
    messages: [
      { role: "user", content: "Explain the GHZ state in two sentences." },
    ],
  });
  console.log(response.choices[0].message.content);
  ```

  ```python Python (Anthropic SDK) theme={"dark"}
  from anthropic import Anthropic

  client = Anthropic(
      base_url="https://api-v2.qbraid.com/api/v1/ai",
      api_key=QBRAID_API_KEY,  # the SDK sends this as x-api-key
  )

  response = client.messages.create(
      model="claude-sonnet-4-6",
      max_tokens=1024,
      messages=[{"role": "user", "content": "Explain the GHZ state in two sentences."}],
  )
  print(response.content[0].text)
  ```
</CodeGroup>

## Use with Claude Code

Claude Code talks the Anthropic wire format, so it can run on your qBraid
quota. Set the base URL and your key, then start it:

```bash theme={"dark"}
export ANTHROPIC_BASE_URL="https://api-v2.qbraid.com/api/v1/ai"
export ANTHROPIC_API_KEY="$QBRAID_API_KEY"
claude
```

`ANTHROPIC_API_KEY` reaches the gateway as the `x-api-key` header.

## Available models

The `/models` endpoint is the source of truth. Model lineups change, so
query it rather than trusting a list you read somewhere:

```bash theme={"dark"}
curl https://api-v2.qbraid.com/api/v1/ai/models \
  -H "X-API-Key: $QBRAID_API_KEY"
```

The lineup and pay-as-you-go pricing as of August 2026, in USD per
million tokens:

| Model               | Served by    | Input \$/M | Output \$/M | Notes                |
| ------------------- | ------------ | ---------- | ----------- | -------------------- |
| `gpt-5.6-sol`       | Azure OpenAI | 5.00       | 30.00       | cutting-edge default |
| `gpt-5.6-terra`     | Azure OpenAI | 2.50       | 15.00       | experimental         |
| `gpt-5.6-luna`      | Azure OpenAI | 1.00       | 6.00        | experimental         |
| `gpt-5.5`           | Azure OpenAI | 5.00       | 30.00       | strong default       |
| `gpt-5.4`           | Azure OpenAI | 2.50       | 15.00       | balanced             |
| `gpt-5.4-mini`      | Azure OpenAI | 0.75       | 4.50        | fast                 |
| `gpt-5.4-nano`      | Azure OpenAI | 0.20       | 1.25        | fastest, cheapest    |
| `gpt-5.3-codex`     | Azure OpenAI | 1.75       | 14.00       | code-tuned           |
| `claude-opus-5`     | AWS Bedrock  | 5.00       | 25.00       | most capable         |
| `claude-opus-4-8`   | AWS Bedrock  | 5.00       | 25.00       | capable              |
| `claude-sonnet-4-6` | AWS Bedrock  | 3.00       | 15.00       | balanced             |
| `claude-haiku-4-5`  | AWS Bedrock  | 1.00       | 5.00        | fastest              |

Costs draw from your plan's monthly AI quota first, then from credits at
100 credits = \$1. [Usage Quotas](/v2/ai/user-guide/usage-quotas) explains
the switch-over.

Aliases such as `openai/gpt-5.5` and `qbraid/claude-opus-5` resolve to the
same models. Configs written for other gateways usually work unchanged.

## Check your quota

```bash theme={"dark"}
curl https://api-v2.qbraid.com/api/v1/ai/quota \
  -H "X-API-Key: $QBRAID_API_KEY"
```

Returns your LLM subscription state and remaining quota. Streaming
responses also carry standard rate-limit headers.

<Tip>
  The gateway gives your code raw model access. If you want an AI client to act
  on the qBraid platform itself, with tools for devices, jobs, and credits,
  connect the [MCP Server](/v2/ai/integrations/mcp-server). The two work well
  together.
</Tip>
