Text generation

Introduction

Generate text with POST /v1/generations. Set type to text for text, image or video input. The API returns the complete reply in the same request.

Model directory

  • deepseek-flash

    Text

  • deepseek-v4-pro

    Text

  • gemini-3.5-flash-lite

    Text, image, video

  • gpt-6-luna

    Text, image

  • gpt-6.2-sol

    Text

  • gpt-6.2-astra

    Text

  • claude-haiku-5-5

    Text, image

  • claude-opus-5-5

    Text, image

Image or video input

1. Check which models your key can call

Replace YOUR_ANYCAP_KEY with your Anycap connection key. Check the id of each entry in items. Use gemini-3.5-flash-lite to send an image and a video in the same request.

BASH
curl 'https://api.anycap.io/v1/generations/models?type=text' \  -H 'Authorization: Bearer YOUR_ANYCAP_KEY'

2. Encode and send both files

Copy this curl command and replace YOUR_ANYCAP_KEY, ./image.png and ./video.mp4 with your connection key and file paths. Put your question in text. Use curl 8.3.0 or later. For a first run, choose a small image and a short clip. This command reads both files with --variable and encodes them locally with :b64. Some versions of curl can fail during this step, before sending the request. For larger files, you can prepare the JSON separately and send it with curl --data-binary @request.json.

BASH
curl -sS -X POST 'https://api.anycap.io/v1/generations' \  -H 'Authorization: Bearer YOUR_ANYCAP_KEY' \  --variable 'image@./image.png' \  --variable 'video@./video.mp4' \  --expand-json '{    "type": "text",    "model": "gemini-3.5-flash-lite",    "input": {      "messages": [        {          "role": "user",          "content": [            { "type": "text", "text": "Describe the image and summarize what happens in the video." },            {              "type": "image_url",              "image_url": { "url": "data:image/png;base64,{{image:b64}}" }            },            {              "type": "video_url",              "video_url": { "url": "data:video/mp4;base64,{{video:b64}}" }            }          ]        }      ]    },    "parameters": { "stream": false }  }'
  • Images: use image_url.url for PNG, JPEG, WebP or GIF. Including history, gemini-3.5-flash-lite accepts up to 3,000 images. The other image-capable models listed above accept up to 20, with a 5 MiB limit per original image sent as Base64.
  • Videos: use gemini-3.5-flash-lite and add one video_url.url per MP4, WebM or MOV file. Include up to 5 videos across the request and its history. Send images and videos as Base64 data URLs and set stream to false.
  • For this model, the complete JSON request must fit within 100 MiB, including Base64 data, the prompt and conversation history.

3. Read the generated text

The curl command above returns the result directly. On HTTP 200, read the answer from output.choices[0].message.content. The example shows the relevant fields.

JSON
{  "type": "text",  "output": {    "choices": [      {        "message": {          "role": "assistant",          "content": "The image shows a red bicycle. In the video, a cyclist rides it through a park."        }      }    ]  }}

If the request contains six videos including history, the API returns HTTP 400. Read error.code for the machine-readable code, error.reason for the reason identifier and error.message for the explanation. The example shows the relevant error fields.

JSON
{  "error": {    "code": "invalid_input",    "reason": "model_input_not_supported",    "message": "At most 5 videos are allowed per request, including history."  }}

Text-only request

Call POST /v1/generations with type set to text. Put your prompt in input.messages. The response contains the complete answer.

BASH
curl -X POST https://api.anycap.io/v1/generations \  -H "Authorization: Bearer YOUR_ANYCAP_KEY" \  -H "Content-Type: application/json" \  -d '{    "type": "text",    "model": "deepseek-flash",    "input": { "messages": [{ "role": "user", "content": "hello" }] },    "parameters": { "max_tokens": 128, "reasoning_effort": "low" }  }'
FieldMeaning
input.messages
Messages in conversation order, each with a role and content.
parameters
Chat fields such as temperature and max_tokens.
parameters.reasoning_effort
Optional for deepseek-flash and deepseek-v4-pro. Accepts none, low, high or max.
model
From GET /v1/generations/models?type=text.

Web search and URL reading

Send X-Anycap-Web-Tools: auto with deepseek-flash on POST /v1/generations. The model decides when to search or read a link. Use search for search only or read for URL reading only. With thinking enabled and search available, the model can open search results as part of its reasoning. Use read to focus on links from the last user message. Omit tools or send an empty array when using the header.

In the Anycap conversation workspace, ordinary deepseek-flash messages enable web tools automatically on supported sources.

For current developments, search-enabled requests use the current date in Asia/Shanghai. The model is instructed to look for newer evidence, give the dates of its citations where available, and say when it cannot verify a more recent update. Anycap logs publication-date checks using the source metadata returned with citations.

BASH
curl https://api.anycap.io/v1/generations \  -H "Authorization: Bearer YOUR_ANYCAP_KEY" \  -H "Content-Type: application/json" \  -H "X-Anycap-Web-Tools: auto" \  -d '{"type":"text","model":"deepseek-flash","input":{"messages":[{"role":"user","content":"Find this week’s news on public transit and cite your sources."}]}}'
Full text generation document →