Docs & support
From your first line of code to your next product.
Quick start
Set up an API key, choose a model and check your quota before sending your first request.
Model calls use Relay API keys. Dashboard access tokens and PATs cannot replace them.
Environment setup
Store your API key in a server environment variable and configure your SDK with the Base URL below.
https://keda8.ai/v1Bearer $AI_API_KEYapplication/jsonexport AI_API_KEY="YOUR_RELAY_API_KEY"
export AI_BASE_URL='https://keda8.ai/v1'
Replace YOUR_RELAY_API_KEY with your own key. These variables apply to the current terminal session; run subsequent code in the same terminal. Do not append /v1 twice.
Code examples
Choose a language and copy a complete example. Standard requests return the full result; streaming requests deliver output as it arrives.
curl --fail-with-body "https://keda8.ai/v1/chat/completions" \
--connect-timeout 10 --max-time 60 \
-H "Authorization: Bearer $AI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_CONFIGURED_MODEL_ID",
"messages": [
{
"role": "user",
"content": "Hello!"
}
],
"stream": false
}'
bash request.shThis example prints raw JSON or SSE events. The Python and JavaScript SDK examples extract the reply text.
Replace YOUR_CONFIGURED_MODEL_ID with an exact model ID from Models & Pricing. These examples require explicit Chat Completions support. Check model documentation for other capabilities.
Understanding responses
The following examples illustrate the response structure. Fields and token counts are illustrative, not results from an actual request.
{
"id": "chatcmpl-example",
"object": "chat.completion",
"model": "YOUR_CONFIGURED_MODEL_ID",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello!"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 2,
"total_tokens": 11
}
}
choices[0].message.contentRead the complete reply text.
finish_reasonCheck why generation ended, such as stop or length. A length-limited response may need continuation.
usageReview input, output and total tokens. Request logs determine actual billing.
Endpoints & parameters
Paths below are relative to the Base URL. Availability depends on model capabilities, API key permissions and backend configuration.
/chat/completionsThe endpoint used in these examples, for models that explicitly support Chat Completions.
/modelsList models accessible with your Relay API Key. Find pricing on Models & Pricing.
/embeddingsFor models supporting Embeddings. Provide the corresponding model ID and input.
/images/generationsFor image generation models. Parameters and billing depend on the model.
Chat Completions request parameters
| Parameter | Type / requirement | Description |
|---|---|---|
model | stringRequired | The exact model ID from Models & Pricing. Your API key must have access to it. |
messages | arrayRequired | An ordered list of conversation messages, each with a role and content. |
stream | booleanOptional | Set to true for SSE events. Standard requests return a complete JSON response. |
temperature | numberModel dependent | Controls sampling randomness. Supported values depend on the model. |
max_completion_tokens | integerModel dependent | Limits generated tokens. Some models use max_tokens; follow the model's documentation. |
Tool calls, structured output, image input and other parameters are not universal. Start with a minimal request, then add parameters confirmed to be supported.
Troubleshooting
Read the HTTP status and error body, then check the relevant configuration. Upstream services may map errors differently; use the actual message to diagnose the issue.
400Check your JSON, required fields, context length and whether the model supports your parameters.
401Use a valid Relay API Key and check for extra whitespace after Authorization: Bearer.
402 / 403Read the error body and check your balance, key quota, group, model permissions and IP restrictions.
404Check that your Base URL contains /v1 only once, and verify the exact model ID and endpoint.
429Read the error body to distinguish rate limits from quota limits. Reduce concurrency and honor Retry-After when applicable.
5xxSave the error body and request ID, then check your logs. Use bounded backoff only after confirming a retry is appropriate.
TIMEOUTCheck your network, proxy buffering and client timeout. A partial response should not be treated as a complete answer.
A network error does not necessarily mean a request was not processed. After a timeout or interrupted stream, check your logs before resubmitting.
Common questions
Troubleshooting & support
Having trouble with a request? Start with your API key, model configuration and request logs.
Record the time, model ID, endpoint, SDK version and full error details. Remove API keys and sensitive content before sharing.