Text generation
Introduction
Text generation is OpenAI-compatible. POST /v1/chat/completions returns native JSON, or server-sent events when stream is true. The assistant text is in choices[0].message.content.
Unified API (recommended)
New integrations call POST /v1/generations with type=text. The OpenAI-compatible endpoints below remain supported, including streaming.
BASH
curl -X POST https://api.anycap.io/v1/generations \ -H "Authorization: Bearer $ANYCAP_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "type": "text", "model": "<model from GET /v1/generations/models?type=text>", "input": { "messages": [{ "role": "user", "content": "hello" }] }, "parameters": { "max_tokens": 128 } }'FieldMeaning
input.messages
OpenAI-style messages; the reply is returned in
output.parameters
Chat fields such as
temperature and max_tokens.model
From
GET /v1/generations/models?type=text.| Step | Method and path | Success |
|---|---|---|
| List authorized models | GET /v1/models | 200 |
| Generate | POST /v1/chat/completions | 200 |
JSON
{ "model": "<exact-model>", "messages": [{ "role": "user", "content": "Say hello in one sentence." }], "max_tokens": 32, "stream": false}Idempotency-Key: your own key for the logical call, persisted by you. It may be any opaque string of at most 255 bytes (a readable label such astest-001is fine); the returned taskidis the identity, and when your key is a UUID the task id equals it. The platform scopes keys to your connection, so retrying the same key never submits twice.X-Anycap-Source: pin the authorized source and its model, channel and price.X-Anycap-Channel: select a saved channel slug.
PreviousUnified API