API Reference

Text Generation

Generate chat completions and long-form content.

All documentation

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 caseSuggested range
Code generation0.10.3
Technical writing0.30.5
General content0.50.8
Creative writing0.71.2
Brainstorming1.01.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"
  }
}
FieldDescription
contentGenerated text
tokens_usedTokens deducted from your balance
actual_tokensProvider-reported token usage when available
remaining_tokensBalance after this request
usage_percentagePercent 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.