/v1/chat/completionsOpenAI chat completions
Gab AI for developers
Build chat, research and creative tools with one Gab AI key. Use OpenAI-compatible Chat Completions and Responses or Anthropic-style Messages, choose your model, and connect the clients you already use.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["GAB_API_KEY"],
base_url="https://gab.ai/v1",
)
response = client.chat.completions.create(
model="arya",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello, how are you?"}
],
)
print(response.choices[0].message.content)import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.GAB_API_KEY,
baseURL: 'https://gab.ai/v1',
});
const response = await client.chat.completions.create({
model: 'arya',
max_tokens: 1024,
messages: [
{ role: 'user', content: 'Hello, how are you?' },
],
});
console.log(response.choices[0].message.content);curl https://gab.ai/v1/chat/completions \
-H "Authorization: Bearer $GAB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "arya",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello, how are you?"}]
}'# Claude Code speaks Anthropic's /v1/messages API.
# Point it at the root domain — the client appends /v1/messages itself.
export ANTHROPIC_BASE_URL="https://gab.ai"
export ANTHROPIC_AUTH_TOKEN="YOUR_GAB_API_KEY"
export ANTHROPIC_MODEL="auto"
export ANTHROPIC_SMALL_FAST_MODEL="arya"
claude# Merge into your user config; set GAB_API_KEY privately before launch.
# Full setup and verification: /docs/codex-cli
model = "arya"
model_provider = "gab"
[model_providers.gab]
name = "Gab AI"
base_url = "https://gab.ai/v1"
env_key = "GAB_API_KEY"
wire_api = "responses"
requires_openai_auth = false
supports_websockets = false# Hermes works with any OpenAI-compatible endpoint.
# Run 'hermes model', choose "Custom endpoint", then supply:
#
# API base URL: https://gab.ai/v1
# API key: YOUR_GAB_API_KEY
# Model name: auto (or any id from /v1/models)
hermes# Prime Agent uses a custom provider in ~/.prime/agent/models.json.
# Point baseUrl at Gab AI, then launch with --provider gab-ai.
export GAB_AI_API_KEY="YOUR_GAB_API_KEY"
prime-agent --provider gab-ai --model autoStart with Chat Completions, Responses or Messages. Each uses the same Gab AI key with its own request format.
Choose the protocol and base URL for your client
| Request format | Client base URL | Request endpoint | Setup reference |
|---|---|---|---|
| OpenAI-style Chat Completions | https://gab.ai/v1 | POST /v1/chat/completions | OpenAI SDK and compatible chat clientsFirst request |
| OpenAI-style Responses | https://gab.ai/v1 | POST /v1/responses | Codex uses a named Responses providerCodex setup |
| Anthropic-style Messages | https://gab.ai for clients that append /v1/messages | POST /v1/messages | Claude Code CLI gateway variablesClaude Code setup |
Choose your client’s request format, then follow its setup guide for the base URL and model settings.
Use Gab as a multi-model LLM API for your app: one key connects to the offered models without managing a separate key for each provider. Point a compatible OpenAI client at Gab’s base URL, or use the Messages format for a client that expects it. Follow the protocol reference for supported fields and features.
Match the model to the work before paying for more capacity than the task needs.
For a lower-cost API workflow, compare the current rates for models that support your inputs and tools. Start with a small representative request, then increase context or output only when the result needs it. Longer histories, reasoning and extra tool calls can increase usage.
Compare the cost of completing the task, including useful revisions, rather than a token rate alone. Read the completed request’s usage and keep your app’s output budget explicit.
Model costs and API billingMeet Auto Router
Choose a model by name for your task, or let Auto route your request. For coding, it considers the complexity of the work ahead.
Syntax, one-liners, short explanations
One contained unit of work
Repo-scale, multi-file, security-sensitive
For supported coding agents, the selected model stays consistent through a tool loop. A new task can be routed again.
Find the selected model in the response and the X-Gab-Routed-Model header.
from openai import OpenAI
client = OpenAI(
api_key="YOUR_GAB_API_KEY",
base_url="https://gab.ai/v1",
)
# Auto Router classifies the kickoff (quick / standard / hard for coding)
# and sticks that model for a Cursor / Claude Code / Codex tool loop.
response = client.chat.completions.create(
model="auto",
messages=[
{"role": "user", "content": "Write a debounce helper and tests"}
],
)
print(response.model) # slug that actually ran
# Also inspect X-Gab-Routed-Model, X-Gab-Router-Intent, X-Gab-Router-Coding-Tier
print(response.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.GAB_API_KEY,
baseURL: "https://gab.ai/v1",
});
const response = await client.chat.completions.create({
model: "auto",
messages: [
{ role: "user", content: "Write a debounce helper and tests" },
],
});
console.log(response.model); // The model that ran
console.log(response.choices[0].message.content);curl --include https://gab.ai/v1/chat/completions \
--header "Authorization: Bearer $GAB_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "auto",
"messages": [
{
"role": "user",
"content": "Write a debounce helper and tests"
}
]
}'
# The JSON response names the model that ran.
# --include also shows the X-Gab-Routed-Model header.Fits your workflow
Connect your editor, coding agent or scripts using the matching API format. Each guide shows the base URL, credentials and model settings.
Ask about your code and draft changes with Gab models in Cursor chat.
Setup guideSet up Claude Code to use Gab models in your terminal coding workflow.
Setup guideAdd Gab as a model provider for your Codex projects.
Setup guideChoose Gab models for code explanations, planning and edits in OpenCode.
Setup guideFollow the guide for your installed client version.
Use Chat Completions to turn source notes into a proposal, then refine the answer with a follow-up.
The workshop proposal includes 24 proposed participants at USD 20 each, generating USD 480 in income. After subtracting the USD 370 base cost, the remaining funds are USD 110 before unspecified tax and delivery. Currently, no date, venue, or approval exists for the event.
Write three short sentences for a workshop proposal using only these facts: 24 proposed participants at USD 20 gives USD 480 income. Base cost is USD 370, so remaining funds are USD 110 before unspecified tax and delivery. No date, venue or approval exists. State the figures and unknowns clearly; do not invent details. Maximum 60 words.Ask for the next step while keeping the figures and unknowns. The follow-up adds a request to confirm tax and delivery before approval.
The workshop proposes 24 participants at USD 20, yielding USD 480 income. The base cost is USD 370, leaving USD 110 before unspecified tax and delivery. No date, venue, or approval exists. Please confirm tax and delivery before approving the proposal.
Keep those figures and unknowns. Add a direct next action asking the group to confirm tax and delivery before approving the proposal. Use no more than 60 words.The API reference
Create chat experiences, generate images, videos and speech, work with files, and manage API keys and usage.
/v1/chat/completionsOpenAI chat completions
/v1/responsesOpenAI responses
/v1/messagesAnthropic messages
/v1/modelsList available models
/v1/models/{id}Retrieve a model by slug or alias
/v1/responses/{id}Retrieve a stored Responses result
/v1/agent-setupGenerated Cursor / OpenCode / OpenClaw configs
/openapi.jsonOpenAPI spec
/llms-full.txtGenerated model catalog for agents
/v1/images/generationsImage generation
/v1/images/editImage editing (reference images)
/v1/images/{id}Delete a generated image
/v1/videos/generationsVideo generation
/v1/audio/speechText to speech
/v1/embeddingsEmbeddings
/v1/filesUpload files for reuse
/v1/filesList API-created files
/v1/files/{id}Delete an API file
/v1/creditsCredit balance
/v1/api-keysAPI key management
/v1/account/exportFull account export
Yes. Use https://gab.ai/v1 with your Gab API key for supported Chat Completions and Responses requests. The quickstart shows the request format; the endpoint reference explains fields and model capabilities.
Use https://gab.ai/v1 for OpenAI-style clients. Clients such as Claude Code that append /v1/messages use https://gab.ai. Follow the setup guide for your client version.
Yes. Authenticated API requests require active Plus or Plus Premium and applicable credits.
No. API requests use credits separately from Arya’s included use in Plus Chat.
Start building
Authenticated API access requires Plus or Plus Premium and applicable credits. Create a key, follow the quickstart, and build from there.