---
title: "Generate text (chat)"
method: POST
path: "/v1/ai/text"
tags: ["Text"]
---

# Generate text (chat)

`POST /v1/ai/text`

## Request

- Base URL: `https://apihub.co.il`
- URL: `https://apihub.co.il/v1/ai/text`
- Auth: HTTP bearer

Any writing task with the Gemini model you choose: a prompt or a conversation, optional system instructions, JSON answers. Add `media` and the model watches and listens too: understand a video to the second (what is said, shown and felt), plan an edit, read a PDF, describe images — or give a public YouTube link and the model watches it in place (find the strongest moments with timestamps, write a script from it; nothing is downloaded). Billed by the exact tokens the model reports (a video ≈ 300 tokens per second at 1 fps).

**Billing:** By the tokens / images / seconds the model reports — see GET /v1/ai/models for prices · **Rate limit:** 60/min

## Headers

- `Idempotency-Key` string
- `X-Tag` string

## Request body

- object
  - `json` boolean: Ask for a JSON answer
  - `media` object[]: Files the model sees and hears together with the prompt: a video (what happens on screen and when, with its sound — ask for timestamps), images, audio, PDFs. Up to 1 GB each (big videos take a few minutes to upload — send x-wait-ms or poll). A public YouTube link works too (no download; use start/end for one part of a long video)
    - `end` number: Video / audio: look only until this second
    - `fps` number: Video: frames per second the model looks at (default 1; 2–4 for fast action or timing to the frame)
    - `url` string, uri, required: Public URL of the file — e.g. an upload from POST /v1/studio/uploads or a render — or a public YouTube link (watch / shorts / youtu.be): the model watches it directly, nothing is downloaded; one YouTube link per request
    - `type` 'video' | 'image' | 'audio' | 'pdf': Detected from the file when omitted
    - `start` number: Video / audio: look only from this second
  - `model` 'auto' | 'gemini-3.8-flash' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.1-pro-preview' | 'gemini-3.1-flash-lite': A model id (GET /v1/ai/models) or "auto" — then `quality` decides: fast=gemini-3.1-flash-lite, balanced=gemini-3.5-flash, best=gemini-3.1-pro-preview
  - `prompt` string: Single-turn prompt (or use messages)
  - `system` string
  - `quality` 'fast' | 'balanced' | 'best': Which model auto picks: fast (cheapest) · balanced (default) · best (strongest, costs more)
  - `messages` object[]
    - `role` 'user' | 'assistant', required
    - `content` string, required
  - `max_tokens` integer: The longest answer, in tokens. A model that thinks first (Gemini 3.5 Flash, 3.8 Flash, 3.1 Pro) gets room to think on top of it — up to 8,192 tokens, billed as output like the answer — so the thinking never cuts the answer short
  - `temperature` number

## Response `200`

Completed

- object
  - `id` string: Execution id — stable across internal retries; use it with GET /v1/executions/{id}
  - `status` 'pending' | 'processing' | 'completed' | 'partial' | 'failed' | 'cancelled' | 'timeout'
  - `operation` string
  - `tag` string, nullable: Your X-Tag, if sent
  - `created_at` string, date-time
  - `completed_at` string, date-time, nullable
  - `output` object: Operation result (see each operation). While a Studio render is processing: `stage` (queued · transcribing · downloading · preparing · cleaning_voice · mixing_audio · rendering · finishing), `phase` (the engine's: download · prepare · voice · audio · encode · qa · upload, or null), `progress` (a percent, 0–100) and `progress_fraction` (0–1), `eta_seconds` (seconds left, never below 0) and `estimate_seconds`
  - `error` string, nullable
  - `usage` object
    - `credits_charged` number, nullable
    - `credits_reserved` number
    - `estimated_credits` number
    - `cost_source` 'provider_reported' | 'calculated' | 'estimated' | 'null', nullable
    - `provider_usage` object, nullable: Normalised consumption, e.g. { VIDEO_SECOND: 22.4 }
  - `balance` object
    - `available` number
    - `reserved` number

## Other responses

- `400`: Invalid input
- `402`: Insufficient credits / project budget
- `404`: Resource not found (or not yours)
- `429`: Rate limited
- `503`: Service temporarily paused

---

[API](https://skmtc.dev/apihub/apis/apihub-one-api-for-chat-image-video-ai.md) · [All operations](https://skmtc.dev/apihub/apis/apihub-one-api-for-chat-image-video-ai/llms.txt) · [OpenAPI document](https://skmtc.dev/apihub/apis/apihub-one-api-for-chat-image-video-ai/revisions/a8caa42835ce?raw)
