---
title: "Generate text"
method: POST
path: "/api/v1/generate/text"
---

# Generate text

`POST /api/v1/generate/text`

Generate text for a specific workflow

## Request body

- AiCompletionRequest
  - `input` string, required — The input text to generate a response for
  - `workflowSlug` string, required — The slug of the Workflow to use for generation (can be found in the Itzam dashboard)
  - `groupId` string — Optional identifier for grouping related runs (e.g. user ID, session ID, etc.)

## Response `200`

Successfully generated content (we also return the run ID in the header X-Run-ID)

- GenerateTextResponse
  - `text` string, required — The generated output text
  - `metadata` object, required
    - `runId` string, required — The ID of the run created for this generation
    - `cost` string, required — The cost of the run
    - `model` object, required
      - `name` string, required — The name of the model used for this generation
      - `tag` string, required — The tag of the model used for this generation
    - `durationInMs` number, required — The duration of the run in milliseconds
    - `inputTokens` number, required — The number of input tokens used for this generation
    - `outputTokens` number, required — The number of output tokens used for this generation

## Other responses

- `400` — Bad request - invalid input
- `401` — Unauthorized - invalid API key
- `403` — Forbidden - organization does not have an active subscription
- `404` — Not found - workflow not found
- `500` — Server error during generation

---

[API](https://skmtc.dev/itzam-ai/apis/itzam-api.md) · [All operations](https://skmtc.dev/itzam-ai/apis/itzam-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/itzam-ai/itzam-api/revisions/cc21b9e9916a/schema)
