Documentation
Everything you need to integrate Tokligence into your applications. Our API is fully compatible with the OpenAI format.
Quick Start
Get started with Tokligence in just a few steps:
- Create an account and get your API key from the Dashboard
- Set your API base URL to
http://localhost:8081/v1 - Use your API key in the
Authorization: Bearerheader - Start making requests using OpenAI-compatible format
Code Examples
Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(
api_key="tk-xxxxxxxxxxxx", # Your Tokligence API key
base_url="http://localhost:8081/v1"
)
response = client.chat.completions.create(
model="claude-3-5-sonnet", # Check /models for available models
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(response.choices[0].message.content)cURL
curl http://localhost:8081/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer tk-xxxxxxxxxxxx" \
-d '{
"model": "claude-3-5-sonnet",
"messages": [
{"role": "user", "content": "Hello!"}
]
}'JavaScript / TypeScript
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'tk-xxxxxxxxxxxx', // Your Tokligence API key
baseURL: 'http://localhost:8081/v1'
});
const response = await client.chat.completions.create({
model: 'claude-3-5-sonnet', // Check /models for available models
messages: [
{ role: 'user', content: 'Hello!' }
]
});
console.log(response.choices[0].message.content);Streaming (Python)
from openai import OpenAI
client = OpenAI(
api_key="tk-xxxxxxxxxxxx",
base_url="http://localhost:8081/v1"
)
stream = client.chat.completions.create(
model="claude-3-5-sonnet",
messages=[{"role": "user", "content": "Write a story"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")API Reference
Chat Completions
Create chat completions with any supported model. Supports both streaming and non-streaming modes.
POST /v1/chat/completionsList Models
Retrieve a list of all available models with pricing info.
GET /v1/modelsList Providers
Get information about available LLM providers.
GET /v1/providersEmbeddings
OptionalCreate embeddings for text inputs (if enabled).
POST /v1/embeddingsImage Generation
OptionalGenerate images using DALL-E or other providers (if enabled).
POST /v1/images/generationsRerank
OptionalRerank documents based on relevance (if enabled).
POST /v1/rerankEndpoints marked as "Optional" may not be available depending on your deployment configuration. Contact your administrator for details.
Authentication
All API requests require authentication using an API key. Include your API key in the Authorization header:
Authorization: Bearer tk-xxxxxxxxxxxxAPI keys start with tk- prefix.
You can create and manage your API keys in the Dashboard → API Keys.
For organizations, API keys can be managed at Organization → API Keys.
Supported Models
Available models are dynamically configured by administrators. Common providers include:
Anthropic
Claude family models including Sonnet, Opus, and Haiku variants
OpenAI
GPT-4, GPT-4o, GPT-3.5 Turbo and other OpenAI models
Gemini family models with multimodal capabilities
DeepSeek
Cost-effective models for chat and coding tasks
Azure OpenAI
Enterprise-grade OpenAI models via Azure
More Providers
Additional providers can be configured by administrators
View the complete list of currently available models and pricing on the Models page.
Rate Limits
Rate limits are configured per API key and may vary based on your plan. The following headers are included in API responses:
X-RateLimit-Limit: 60 # Max requests per window X-RateLimit-Remaining: 58 # Requests remaining X-RateLimit-Reset: 1699999999 # Window reset timestamp
If you exceed your rate limit, the API returns 429 Too Many Requests. Wait until the reset time or contact your administrator for limit increases.
Error Handling
The API returns standard HTTP status codes and JSON error responses:
400Bad Request
Invalid request parameters or model not allowed
401Unauthorized
Missing or invalid API key
402Insufficient Balance
Account balance is too low for this request
429Too Many Requests
Rate limit exceeded
503Service Unavailable
Upstream provider error or server shutting down
Ready to Get Started?
Create a free account and start building with our API today.