API Reference
Text Generation
Generate chat completions and long-form content.
Generate chat completions, articles, code, summaries, and more with type: "text" (the default).
Request
POST /api/external/ai
Content-Type: application/json
X-API-Key: your-api-key-here
{
"prompt": "Explain machine learning in simple terms",
"model": "deepseek-chat",
"provider": "deepseek",
"type": "text",
"max_tokens": 1000,
"temperature": 0.7
}
Parameters
| Parameter | Type | Default | Description |
| — | — | — |
| prompt | string | — | Required. User prompt |
| model | string | — | Required. Model id or name |
| provider | string | deepseek | AI provider |
| type | string | text | Must be text for this flow |
| max_tokens | number | 2000 | Max output tokens |
| temperature | number | 0.7 | Randomness from 0.0 to 2.0 |
Temperature guidance
| Use case | Suggested range |
|---|---|
| Code generation | 0.1 – 0.3 |
| Technical writing | 0.3 – 0.5 |
| General content | 0.5 – 0.8 |
| Creative writing | 0.7 – 1.2 |
| Brainstorming | 1.0 – 1.5 |
Success response
{
"success": true,
"data": {
"content": "Machine learning is a subset of artificial intelligence...",
"model": "deepseek-chat",
"provider": "deepseek",
"tokens_used": 150,
"actual_tokens": 148,
"cost": 0.0003,
"remaining_tokens": 9850,
"usage_percentage": "1.5"
}
}
| Field | Description |
|---|---|
content | Generated text |
tokens_used | Tokens deducted from your balance |
actual_tokens | Provider-reported token usage when available |
remaining_tokens | Balance after this request |
usage_percentage | Percent of plan usage consumed |
Example prompts
Creative writing
{
"prompt": "Write a short story about a robot discovering emotions",
"model": "gpt-4",
"provider": "openai",
"type": "text",
"max_tokens": 1500,
"temperature": 0.9
}
Code generation
{
"prompt": "Create a Python function to calculate the Fibonacci sequence",
"model": "deepseek-coder",
"provider": "deepseek",
"type": "text",
"max_tokens": 500,
"temperature": 0.1
}
Summarization
{
"prompt": "Summarize the key benefits of renewable energy in 3 bullet points",
"model": "gpt-3.5-turbo",
"provider": "openai",
"type": "text",
"max_tokens": 200,
"temperature": 0.3
}
Requirements
- Active subscription
- Sufficient remaining tokens
- Provider available and allowed on your API key
- Model available and allowed on your API key
If tokens are insufficient, the API returns 402 with required vs remaining token details.