Learn how to authenticate with the Gab AI API using API keys. Understand rate limits and secure your requests.
To use the Gab AI API, you need an API key. Here's how to get one:
Your API key grants access to your account and credits. Never share it publicly, commit it to version control, or expose it in client-side code.
Include your API key in the Authorization header of all API requests:
Real Gab AI keys start with the gab_ or gab- prefix followed by hex characters (32–64 hex chars depending on which flow created the key). Treat the entire string as opaque — do not parse it.
When using OpenAI-compatible SDKs, configure the base URL and API key:
Store your API key in environment variables rather than hardcoding it. This improves security and makes it easier to manage across environments.
API requests are rate limited to ensure fair usage and platform stability. All API requests use credits — free default model messages in Plus are not included in API. When you exceed your rate limit, requests return a 429 status code. Implement exponential backoff or check the rate limit headers before making requests.
10,000 requests per day
Custom limits available
All API responses include headers to help you track your rate limit usage:
You can manage your API keys programmatically or through the dashboard:
You can also manage API keys programmatically using the /v1/api-keys endpoint. See the Endpoints documentation for details.
If authentication fails, you'll receive one of these errors:
Your API key grants access to your account and credits. Never share it publicly, commit it to version control, or expose it in client-side code.
Authorization: Bearer YOUR_API_KEY
curl https://gab.ai/v1/chat/completions \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer gab_5e17f695110d1e02c90e4537445d85fc" \\
-d '{
"model": "arya",
"messages": [
{"role": "user", "content": "Hello!"}
]
}'
Real Gab AI keys start with the gab_ or gab- prefix followed by hex characters (32–64 hex chars depending on which flow created the key). Treat the entire string as opaque — do not parse it.
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.GAB_API_KEY,
baseURL: 'https://gab.ai/v1'
});
// Now use the client as normal
const response = await client.chat.completions.create({
model: 'arya',
messages: [{ role: 'user', content: 'Hello!' }]
});
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("GAB_API_KEY"),
base_url="https://gab.ai/v1"
)
# Now use the client as normal
response = client.chat.completions.create(
model="arya",
messages=[{"role": "user", "content": "Hello!"}]
)
Store your API key in environment variables rather than hardcoding it. This improves security and makes it easier to manage across environments.
const response = await fetch('https://gab.ai/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ model: 'arya', messages: [...] })
});
// Check rate limit headers
const limit = response.headers.get('X-RateLimit-Limit');
const remaining = response.headers.get('X-RateLimit-Remaining');
const reset = response.headers.get('X-RateLimit-Reset');
console.log(\`\${remaining}/\${limit} requests remaining\`);
console.log(\`Resets at: \${new Date(reset * 1000)}\`);
You can also manage API keys programmatically using the /v1/api-keys endpoint. See the Endpoints documentation for details.
{
"error": {
"message": "Invalid API key provided",
"type": "authentication_error",
"code": "invalid_api_key",
"param": null
}
}