Loading...
Direct HTTP access to Rax AI
All API requests use this base URL
https://ai.raxcore.dev/api/v1OpenAI Compatible: Our API is fully compatible with OpenAI's API format. You can use existing OpenAI client libraries by changing the base URL.
// JavaScript/TypeScript fetch example
const response = await fetch('https://ai.raxcore.dev/api/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer rax_your_api_key',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'rax-4.0',
messages: [{ role: 'user', content: 'Hello!' }],
}),
});
const data = await response.json();
console.log(data.choices[0].message.content);# Python requests example
import requests
response = requests.post(
'https://ai.raxcore.dev/api/v1/chat/completions',
headers={
'Authorization': 'Bearer rax_your_api_key',
'Content-Type': 'application/json',
},
json={
'model': 'rax-4.0',
'messages': [{'role': 'user', 'content': 'Hello!'}],
},
)
data = response.json()
print(data['choices'][0]['message']['content'])Include your API key in the Authorization header
Authorization: Bearer rax_your_api_key/chat/completionsCreate a chat completion
curl -X POST https://ai.raxcore.dev/api/v1/chat/completions \
-H "Authorization: Bearer rax_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"model": "rax-4.0",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello, how are you?"}
],
"temperature": 0.7,
"max_tokens": 1000
}'{
"id": "req_abc123def456",
"object": "chat.completion",
"created": 1700000000,
"model": "rax-4.0",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! I'm doing well, thank you for asking. How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 18,
"total_tokens": 43
}
}Set stream: true to receive chunks via SSE
curl -X POST https://ai.raxcore.dev/api/v1/chat/completions \
-H "Authorization: Bearer rax_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"model": "rax-4.0",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'data: {"id":"req_abc123","object":"chat.completion.chunk","created":1700000000,"model":"rax-4.0","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"id":"req_abc123","object":"chat.completion.chunk","created":1700000000,"model":"rax-4.0","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
data: {"id":"req_abc123","object":"chat.completion.chunk","created":1700000000,"model":"rax-4.0","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}
data: {"id":"req_abc123","object":"chat.completion.chunk","created":1700000000,"model":"rax-4.0","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]Each line is prefixed with data: . The stream ends with data: [DONE].
/modelsList available models
curl https://ai.raxcore.dev/api/v1/models \
-H "Authorization: Bearer rax_your_api_key"{
"object": "list",
"data": [
{
"id": "rax-4.0",
"object": "model",
"created": 1700000000,
"owned_by": "raxcore",
"context_window": 8192,
"max_tokens": 4096
},
{
"id": "rax-4.5",
"object": "model",
"created": 1700000000,
"owned_by": "raxcore",
"context_window": 8192,
"max_tokens": 4096
}
]
}/usageGet your API usage statistics
curl https://ai.raxcore.dev/api/v1/usage \
-H "Authorization: Bearer rax_your_api_key"{
"object": "usage",
"total_tokens": 150000,
"total_requests": 1500,
"period_start": "2024-01-01T00:00:00Z",
"period_end": "2024-01-31T23:59:59Z",
"breakdown": {
"rax-4.0": {
"tokens": 100000,
"requests": 1000
},
"rax-4.5": {
"tokens": 50000,
"requests": 500
}
}
}Parameters for /chat/completions endpoint
modelrequiredModel ID to use (rax-4.0 or rax-4.5)
messagesrequiredArray of message objects with role and content
temperatureSampling temperature (0-2)
max_tokensMaximum tokens to generate (1-4096)
top_pNucleus sampling threshold (0-1)
streamEnable streaming responses
stopStop sequences to end generation
idstringUnique request identifier
objectstringObject type (chat.completion)
creatednumberUnix timestamp
modelstringModel used for completion
choicesarrayArray of completion choices
choices[].messageobjectResponse message with role and content
choices[].finish_reasonstringWhy generation stopped (stop, length)
usageobjectToken usage statistics
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_request_error",
"code": "invalid_api_key",
"status": 401
}
}bad_requestInvalid request format or parameters
invalid_api_keyInvalid or missing API key
forbiddenAPI key lacks permission for this action
rate_limit_exceededToo many requests, retry after delay
internal_errorServer error, please retry
service_unavailableService temporarily unavailable
Requests are limited to ensure fair usage
60 requests / minute
100,000 tokens / day
600 requests / minute
Unlimited tokens
Rate Limit Headers: Check X-RateLimit-Remaining and X-RateLimit-Reset headers in the response to monitor your usage. When rate limited, the Retry-After header indicates wait time.