---
title: "Generate text"
method: POST
path: "/api/experimental/generate/text"
tags: ["generate"]
---

# Generate text

`POST /api/experimental/generate/text`

## Request

- Base URL: `https://opencode.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://opencode.ai/api/experimental/generate/text`
- Auth: none required

Run one stateless model generation using the server's base configuration and return the assistant text. Uses the base configuration's default model when none is specified.

## Request body

- object
  - `prompt` string, required
  - `model` ModelRef
    - `id` string, required
    - `providerID` string, required
    - `variant` string

## Response `200`

GenerateTextResponse

- GenerateTextResponse
  - `data` object, required
    - `text` string, required

## Other responses

- `400`: InvalidRequestError
- `401`: UnauthorizedError
- `404`: ProviderNotFoundError | ModelNotFoundError | LocationNotFoundError
- `422`: UnsupportedModelError
- `502`: ProviderRequestError
- `503`: ServiceUnavailableError

## Changes

> 50 revisions in range; 1 not diffed.

- **2026-10-27** `d6d739fceba2`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/kaaass/apis/opencode/changes/api/experimental/generate/text/post.md)

---

[API](https://skmtc.dev/kaaass/apis/opencode.md) - [All operations](https://skmtc.dev/kaaass/apis/opencode/llms.txt) - [OpenAPI document](https://skmtc.dev/kaaass/apis/opencode/revisions/4e083d954707?raw)
