AI Gateway
Call GPT and Claude models through the qBraid API with one API key.
The AI Gateway proxies language-model requests through the qBraid API using OpenAI and Anthropic request formats. To use it with your existing SDK, change the base URL and API key.
https://api-v2.qbraid.com/api/v1/aiEvery request authenticates with your qBraid API key in the X-API-Key
header. Create a key at
account.qbraid.com/account/api-keys.
The API Keys guide 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 |
Anthropic routes include /v1 because 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.
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." }]
}'import os
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": os.environ["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)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);import os
from anthropic import Anthropic
client = Anthropic(
base_url="https://api-v2.qbraid.com/api/v1/ai",
api_key=os.environ["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)Use with Claude Code
Claude Code uses the Anthropic request format, so it can use your qBraid quota. Set the base URL and your key, then start it:
export ANTHROPIC_BASE_URL="https://api-v2.qbraid.com/api/v1/ai"
export ANTHROPIC_API_KEY="$QBRAID_API_KEY"
claudeANTHROPIC_API_KEY reaches the gateway as the x-api-key header.
Available models
Query /models for the current model catalog:
curl https://api-v2.qbraid.com/api/v1/ai/models \
-H "X-API-Key: $QBRAID_API_KEY"The response uses the OpenAI model-list format. Each entry includes its canonical id and qBraid metadata under _qbraid:
name,description, andproviderdescribe the model.aliaseslists accepted alternative IDs.capabilitiesdescribes image input, structured outputs, and parallel tool-call control.supportedEndpointslists the generation endpoints that accept the model.pricing.inputCreditsPerMillionTokensandpricing.outputCreditsPerMillionTokensgive the token rates in qBraid credits.
Check supportedEndpoints before selecting a model for Chat Completions, Responses, or Anthropic Messages. Catalog discovery omits models without a callable generation endpoint. A missing pricing block does not mean a model is free.
By default, the catalog reflects the caller’s model-access policy. ?includeLocked=1 also returns plan-locked models with _qbraid.requiredTier when restrictions apply. All current plan tiers allow the catalog, but still have different usage allowances.
See Models and pricing for a dated rate reference that includes the GPT-6 family, GPT-6.1 Sol, Claude Opus 5.5, Claude Sonnet 5, and Claude Fable 5.1. Query the catalog for current IDs and rates before integrating a model.
Costs draw from your plan’s AI allowance first. Spending beyond that allowance requires the effective Auto-switch to Credits policy and sufficient credits. The standard conversion is 100 credits = $1. See AI usage quotas.
Check your quota
curl https://api-v2.qbraid.com/api/v1/ai/quota \
-H "X-API-Key: $QBRAID_API_KEY"The response contains your LLM subscription state and remaining quota. Streaming responses also carry standard rate-limit headers.
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.
Thanks for your feedback.

