Text Generation API
A unified REST API to generate text using 20+ AI models from OpenAI, Google, Anthropic, DeepSeek, Perplexity, and more — all through a single endpoint with a credit-based pricing system.
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /generate/text | Generate text / chat completions from a prompt. |
Parameters
Request body fields for /generate/text:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | — | Model ID to use for generation. See the model list below for all available IDs. |
prompt | string | Yes | — | The user prompt / instruction to send to the model. |
system | string | No | "" | Optional system message to set the model's behavior or persona. |
outputType | string | No | "text" | Output format. Use "text" for plain text or "json" to receive a structured JSON response. |
maxTokens | number | No | model max | Maximum number of output tokens to generate. Minimum value is 100. |
note
When using outputType: "json", instruct the model in your prompt to respond in valid JSON format for best results.
Response example
text
A plain text string from the model.
json
{
"success": true,
"output": "...",
"usage": {
"inputTokens": 0,
"outputTokens": 0,
"creditsDeducted": 0
}
}
Examples
Text completion (fetch)
fetch('https://api.imagegpt.online/generate/text', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
model: 'GEMINI-2.5-FLASH-LITE',
system: 'You are a helpful assistant.',
prompt: 'Explain quantum computing in one paragraph.',
outputType: 'text',
maxTokens: 300
})
})
.then(res => res.text())
.then(console.log);
Pricing
Charged in credits per 1,000 output tokens. Input tokens are always free. The credit value shown per model is charged per 1,000 output tokens.
Models
Each model has its own page with parameters, examples, and a live playground.
| Model | Model ID | Credits / 1K tokens |
|---|---|---|
| OPENAI GPT NANO 5.0 | OPENAI-GPT-NANO-5.4 | 4 |
| OPENAI GPT NANO 5.4 | OPENAI-GPT-NANO-5.0 | 3 |
| OPENAI GPT 5.4 | OPENAI-GPT-5.4 | 30 |
| OPENAI GPT 5.5 | OPENAI-GPT-5.5 | 50 |
| OPENAI GPT 6 Astra | OPENAI-GPT-6-ASTRA | 50 |
| GEMINI 2.5 FLASH LITE | GEMINI-2.5-FLASH-LITE | 3 |
| GEMINI 2.5 FLASH LITE SEARCH | GEMINI-2.5-FLASH-LITE-SEARCH | 3 |
| GEMINI 3 FLASH | GEMINI-3-FLASH | 10 |
| GEMINI 3.1 PRO | GEMINI-3.1-PRO | 25 |
| GEMINI 3.1 FLASH LITE | GEMINI-3.1-FLASH-LITE | 15 |
| GEMINI 3.8 FLASH | GEMINI-3.8-FLASH | 20 |
| CLAUDE HAIKU 4.5 | CLAUDE-HAIKU-4.5 | 10 |
| CLAUDE SONNET 4.6 | CLAUDE-SONNET-4.6 | 30 |
| CLAUDE OPUS 4.6 | CLAUDE-OPUS-4.6 | 40 |
| CLAUDE OPUS 4.7 | CLAUDE-OPUS-4.7 | 40 |
| CLAUDE OPUS 4.8 | CLAUDE-OPUS-4.8 | 50 |
| CLAUDE FABLE 5.1 | CLAUDE-FABLE-5.1 | 50 |
| DEEPSEEK V4 FLASH | DEEPSEEK-V4-FLASH | 3 |
| DEEPSEEK V4 PRO | DEEPSEEK-V4-PRO | 7 |
| PERPLEXITY SONAR | PERPLEXITY-SONAR | 3 |
| PERPLEXITY REASONING | PERPLEXITY-REASONING | 10 |
| AWS NOVA MICRO | AWS-NOVA | 3 |
| ALIBABA QWEN3 CODER | QWEN3-CODER | 3 |
| MISTRAL SMALL | MISTRAL-SMALL | 3 |
| MOONSHOT KIMI K2.5 | MOONSHOT-KIMI | 6 |
| MINIMAX M2.7 | MINIMAX M2.7 | 3 |
| MIDI JOURNEY | MIDI-JOURNEY | 5 |
| OPENAI GPT-OSS | OPENAI/GPT-OSS | 1 |
| GOOGLE GEMMA | GOOGLE/GEMMA | 1 |
| META LLAMA | META/LLAMA | 1 |