Skip to content
OpenCode
Esc
navigateopen⌘Jpreview

Generate text

Run one stateless model generation at the requested location and return the assistant text. Uses the location’s default model when none is specified.

POST/api/generate
Query parameters
locationobject | any
Request body
requiredapplication/json
promptstringrequired
modelModel.Ref | any
Show properties
Any of:
Model.Ref
idstringrequired
providerIDstringrequired
variantstring
any
any
Responses
200GenerateTextResponse
dataobjectrequired
Show properties
textstringrequired
400InvalidRequestError
Any of:
InvalidRequestError1
_tagstringrequired
Allowed:InvalidRequestError
messagestringrequired
kindstring | any
Show properties
Any of:
string
string
any
any
fieldstring | any
Show properties
Any of:
string
string
any
any
InvalidRequestError
_tagstringrequired
Allowed:InvalidRequestError
messagestringrequired
kindstring | any
Show properties
Any of:
string
string
any
any
fieldstring | any
Show properties
Any of:
string
string
any
any
401UnauthorizedError
_tagstringrequired
Allowed:UnauthorizedError
messagestringrequired
503ServiceUnavailableError
_tagstringrequired
Allowed:ServiceUnavailableError
messagestringrequired
servicestring | any
Show properties
Any of:
string
string
any
any
Request
curl -X POST "/api/generate" \
  -H "Content-Type: application/json" \
  -d '{
  "prompt": "string",
  "model": {
    "id": "string",
    "providerID": "string",
    "variant": "string"
  }
}'
Response
{
  "data": {
    "text": "string"
  }
}