API Documentation
Everything you need to integrate Frux into your applications. Build powerful AI-powered solutions with our comprehensive API.
Getting Started
The Frux API provides programmatic access to our AI platform. Use it to build chatbots, analyze documents, process images, and more - all while benefiting from our Token Value Preservation technology.
Base URL
https://api.frux.proQuick Start Example
curl -X POST "https://api.frux.pro/api/v1/conversations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "My First Conversation"
}'Save up to 80% with TVP
Our Token Value Preservation technology automatically caches and reuses token patterns. The more you use the API, the more you save!
Authentication
The Frux API supports two authentication methods: API Keys for programmatic access and JWT tokens for user sessions.
API Key Authentication
Use API keys for server-to-server communication. Keys start with th_live_ for production or th_test_ for testing.
Authorization: Bearer th_live_xxxxxxxxxxxxxxxxxxJWT Token Authentication
For user-facing applications, authenticate users and receive a JWT token to make requests on their behalf.
# Login to get JWT token
curl -X POST "https://api.frux.pro/api/v1/auth/login" \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "your_password"}'
# Use the token
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...API Key Management
/api/v1/api-keysCreate a new API key
/api/v1/api-keysList all your API keys
/api/v1/api-keys/:keyIdRevoke an API key
Drop-in Proxy
Keep your existing code and save 20-40% on AI costs. Just change one line to route requests through Frux - we optimize automatically.
Zero Code Changes Required
Your existing Anthropic or OpenAI code works unchanged. Just update the baseURL and start saving immediately.
Anthropic SDK
Use the standard Anthropic SDK with your existing API key. Add one line to enable savings.
// Before - Direct Anthropic call
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({
apiKey: 'sk-ant-xxxxx'
});
// After - Add just ONE line to save 20-40%
const client = new Anthropic({
apiKey: 'sk-ant-xxxxx', // Your key stays the same!
baseURL: 'https://api.frux.pro/v1-proxy'
});
// Your code stays exactly the same
const message = await client.messages.create({
model: 'claude-3-5-sonnet-20241022',
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello!' }]
});OpenAI SDK
Works with the OpenAI SDK exactly the same way. Compatible with all GPT models.
// Before - Direct OpenAI call
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'sk-xxxxx'
});
// After - Same simple change
const client = new OpenAI({
apiKey: 'sk-xxxxx',
baseURL: 'https://api.frux.pro/v1-proxy'
});
// Everything works identically
const completion = await client.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello!' }]
});Use a Frux API Key
Alternatively, use a Frux API key for consolidated billing and enhanced tracking.
// Use a Frux API key instead of provider key
const client = new Anthropic({
apiKey: 'th_live_xxxxx', // Frux API key
baseURL: 'https://api.frux.pro/v1-proxy'
});
// Same API, same code, managed billing through FruxSavings Metrics in Response
Every response includes headers showing exactly how many tokens were saved and the percentage reduction.
# Every response includes savings metrics
X-Frux-Tokens-Original: 10000
X-Frux-Tokens-Optimized: 6000
X-Frux-Tokens-Saved: 4000
X-Frux-Savings-Percent: 40Supported SDKs
- • Anthropic SDK (Python & JS)
- • OpenAI SDK (Python & JS)
- • LangChain
- • Any HTTP client
Benefits
- • 20-40% cost reduction
- • Zero code changes
- • Rollback in seconds
- • Real-time savings tracking
Smart Routing
Intelligent request routing that automatically selects the best service and model for your task. Uses local Qwen model when available for maximum cost savings.
Free Local AI Processing
When preferLocal is enabled (default), requests are routed to our local Qwen2.5-7B model at near-zero cost. Perfect for development, testing, and cost-sensitive applications.
Endpoint
/api/v1/smartProcess a message with automatic service routing and local model optimization
Example Request
# Smart routing with local Qwen model
curl -X POST "https://api.frux.pro/api/v1/smart" \
-H "Authorization: Bearer th_live_xxxxx" \
-H "Content-Type: application/json" \
-d '{
"message": "Explain quantum computing in simple terms",
"preferLocal": true
}'Request Parameters
| Parameter | Type | Description |
|---|---|---|
| message | string | The message or prompt to process (required) |
| conversationId | uuid? | UUID of existing conversation to maintain context |
| preferLocal | boolean? | Use local Qwen model when available (default: true) |
| attachments | array? | Array of file attachments for vision/document processing |
| forceService | string? | Force a specific service: chat, vision, document, data |
Example Response
{
"success": true,
"detectedIntent": {
"service": "chat",
"confidence": 1,
"reasoning": "General question suitable for text conversation"
},
"routedTo": "chat",
"result": {
"message": "Quantum computing is like having a super-powerful calculator...",
"model": "Qwen/Qwen2.5-7B-Instruct",
"isLocal": true
},
"metrics": {
"totalTimeMs": 6074,
"tokensUsed": { "total": 910, "input": 155, "output": 33 }
},
"pricing": {
"costCharged": 0.000013,
"costWithTvp": 0,
"costWithoutTvp": 0.000022,
"userSavings": 0.000009
}
}Available Services
- •
chat- Text conversations and Q&A - •
vision- Image analysis and understanding - •
document- PDF and document processing - •
data- Data analysis and queries
Key Benefits
- • Automatic intent detection
- • Free local model (Qwen2.5-7B)
- • Up to 40% cost savings
- • Persistent conversation context
Chat & Conversations
Create conversations and send messages to AI models. Supports streaming responses for real-time interactions.
Endpoints
/api/v1/conversationsCreate a new conversation
/api/v1/conversationsList all conversations
/api/v1/conversations/:idGet conversation details with messages
/api/v1/conversations/:id/messagesSend a message and get AI response
/api/v1/conversations/:id/messages/streamSend a message with streaming response (SSE)
/api/v1/conversations/:idDelete a conversation
Example: Send a Message
# Send a message and get AI response
curl -X POST "https://api.frux.pro/api/v1/conversations/conv_123/messages" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "Explain quantum computing in simple terms",
"model": "claude-3-5-sonnet-20241022"
}'File Management
Upload and manage files to use in conversations. Supports PDFs, images, and text files up to 50MB.
/api/v1/files/uploadUpload a file (multipart/form-data)
/api/v1/filesList all uploaded files
/api/v1/files/:fileIdGet file metadata
/api/v1/files/:fileId/contentDownload file content
/api/v1/files/:fileIdDelete a file
Example: Upload a File
# Upload a file
curl -X POST "https://api.frux.pro/api/v1/files/upload" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@document.pdf"
# Response
{
"success": true,
"data": {
"fileId": "file_abc123",
"filename": "document.pdf",
"size": 1024000,
"mimeType": "application/pdf"
}
}TVP - Token Value Preservation
Process images, documents, and videos with our proprietary TVP technology. Content is cached as TVP Cards for massive savings on repeated use.
How TVP Saves You Money
When you process a document or image, we create a TVP Card that caches the token representation. Future references to the same content use the cached version, reducing tokens sent to the AI provider by up to 80%.
Image Processing
/api/v1/tvp/visual/processProcess an image synchronously
/api/v1/tvp/visual/process/asyncProcess an image asynchronously (for large files)
/api/v1/tvp/visual/jobs/:jobIdGet async job status
Document Processing
/api/v1/tvp/doc/processProcess a document with OCR
/api/v1/tvp/doc/process/asyncProcess a document asynchronously
Video Processing
/api/v1/tvp/video/processProcess a video file
/api/v1/tvp/video/process-urlProcess a video from URL
TVP Cards Management
/api/v1/tvp/cardsList all your TVP cards
/api/v1/tvp/cards/:cardIdGet a specific TVP card
/api/v1/tvp/cards/:cardIdDelete a TVP card
Example: Process an Image
# Analyze an image with TVP
curl -X POST "https://api.frux.pro/api/v1/tvp/visual/process" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"fileId": "file_abc123",
"prompt": "Describe this image in detail"
}'
# Response includes TVP Card for future savings
{
"success": true,
"data": {
"response": "This image shows...",
"tvpCard": {
"cardId": "tvp_xyz789",
"tokensSaved": 0,
"tokensProcessed": 1500
},
"cost": {
"withTVP": 0.02,
"withoutTVP": 0.02,
"savings": 0
}
}
}
# Subsequent calls with same content use cached tokens
# and show significant savings!Available Models
Access multiple AI models through a single API. All models are included in your pricing tier with no additional cost.
/api/v1/modelsList all available models with pricing
Supported Models
Anthropic Claude
- claude-3-5-sonnet-20241022
- claude-3-opus-20240229
- claude-3-haiku-20240307
OpenAI GPT
- gpt-4o
- gpt-4o-mini
- gpt-4-turbo
Google Gemini
- gemini-1.5-pro
- gemini-1.5-flash
Meta Llama
- llama-3.2-90b-vision
- llama-3.1-70b
Errors & Rate Limits
The API uses standard HTTP status codes and returns detailed error messages in JSON format.
| Code | Status | Description |
|---|---|---|
| 400 | Bad Request | Invalid request parameters or malformed JSON |
| 401 | Unauthorized | Missing or invalid authentication credentials |
| 403 | Forbidden | Valid credentials but insufficient permissions |
| 404 | Not Found | Requested resource does not exist |
| 429 | Too Many Requests | Rate limit exceeded, slow down requests |
| 500 | Internal Server Error | Internal server error, please retry or contact support |
Error Response Format
{
"success": false,
"error": "Error message here",
"code": "ERROR_CODE",
"timestamp": "2025-12-31T00:00:00.000Z"
}Rate Limiting
The API includes rate limit information in response headers. Default limit is 100 requests per minute.
# Rate limit headers in response
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 99
X-RateLimit-Reset: 1735689600Ready to Start Building?
Create your free account to get API access and start building AI-powered applications today.
Get Your API Key