Skip to main content

API Reference

The Radicalbit AI Gateway implements the OpenAI Chat Completions API specification, making it compatible with existing OpenAI libraries and tools.

Base URL

http://localhost:8000

Authentication

API Key Authentication

curl -H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
http://localhost:8000/v1/chat/completions

Endpoints

Chat Completions

Endpoint: POST /v1/chat/completions

Description: Creates a completion for the provided chat messages.

Request Body:

{
"model": "route-name",
"messages": [
{
"role": "user",
"content": "Hello, how are you?"
}
],
"temperature": 0.7,
"max_tokens": 100,
}

Parameters:

ParameterTypeRequiredDescription
modelstringYesThe route name from your configuration
messagesarrayYesArray of message objects
temperaturenumberNoSampling temperature (0.0 to 2.0)
max_tokensnumberNoMaximum tokens to generate
top_pnumberNoNucleus sampling parameter
stopstring/arrayNoStop sequences
presence_penaltynumberNoPresence penalty (-2.0 to 2.0)
frequency_penaltynumberNoFrequency penalty (-2.0 to 2.0)

Message Object:

{
"role": "user|assistant|system",
"content": "Message content"
}

Response:

{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "route-name",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! I'm doing well, thank you for asking."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 8,
"total_tokens": 18
}
}

Embeddings

Endpoint: POST /v1/embeddings

Description: Creates an embedding for the provided input.

Request Body:

{
"model": "route-name",
"input": "The text to embed"
}

Parameters:

ParameterTypeRequiredDescription
modelstringYesThe route name with embedding models
inputstring/arrayYesText to embed (string or array of strings)

Response:

{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.1, 0.2, 0.3, ...]
}
],
"model": "route-name",
"usage": {
"prompt_tokens": 5,
"total_tokens": 5
}
}

Error Responses

Standard Error Format

{
"error": {
"message": "Error description",
"type": "invalid_request_error",
"code": "route_not_found"
}
}

Common Error Codes

CodeDescriptionSolution
route_not_foundRoute name not found in configurationCheck route name in config.yaml
model_not_foundModel not found in routeVerify model configuration
guardrail_blockedContent blocked by guardrailReview guardrail configuration
rate_limit_exceededRate limit exceededAdjust rate limiting configuration
token_limit_exceededToken limit exceededAdjust token limiting configuration
authentication_failedInvalid API keyCheck API key format and permissions