Skip to content

API: AI providers

Start a text generation with the provider of a connection; the job waits for approval and shows its estimate

POST /api/v1/text/generate: Start a text generation with the provider of a connection; the job waits for approval and shows its estimate

Last updated:

POST/api/v1/text/generate

Authentication#

Send the secret in the header Authorization: Bearer <secret>: the local token in local mode, an API key in network mode. An API key needs the edit scope; the local token has every scope. See the API overview for both modes.

Request body#

Content type application/json.

NameTypeRequiredDescription
connection_idstringyesThe connection to the provider that writes the text.. min length 1
dry_runbooleannotrue answers the job it would create, with its estimate, and writes and sends nothing.
max_tokensintegernoThe most tokens the model may write; the default is 1024. The estimate counts all of them.
modelstringyesThe model id, as provider:models lists it.. min length 1
project_idstringyesThe project the generation belongs to, prj_ and 10 characters.. min length 1
promptstringyesWhat to write, 1 to 100000 characters.. min length 1
systemstringnoInstructions for the model, at most 20000 characters.
temperaturenumber (double) or nullno0 to 2; leave out for the default of the provider.
wait_msintegernoWait up to this many milliseconds for the job to finish.

Responses#

202 Accepted#

Content type application/json. Schema: Job.

NameTypeRequiredDescription
actorstringno
approval_idstringno
created_atstring (date-time)no
dry_runbooleanno
errorError or any or null or nullno
estimateMoney or any or null or nullno
finished_atstring (date-time) or nullno
job_idstringno
kindstringno
lintLintTotals or any or null or nullno
messagestringno
progressnumber (double)no
project_idstring or nullno
resultJobResult or any or null or nullno
started_atstring (date-time) or nullno
statestringno
textstringno
warningsarray of stringno

400#

Validation failed; errors maps each field to its messages and issues lists each problem with its code, key and params

Content type application/problem+json. Schema: Problem.

401 Unauthorized#

Error (RFC 9457 problem details)

Content type application/problem+json. Schema: Problem.

403#

Error (RFC 9457 problem details)

Content type application/problem+json. Schema: Problem.

409#

Error (RFC 9457 problem details)

Content type application/problem+json. Schema: Problem.

422 Unprocessable Content#

Error (RFC 9457 problem details)

Content type application/problem+json. Schema: Problem.

429#

Error (RFC 9457 problem details)

Content type application/problem+json. Schema: Problem.

Any other status#

Error (RFC 9457 problem details)

Content type application/problem+json. Schema: Problem.

curl -X POST "http://127.0.0.1:7878/api/v1/text/generate" \
  -H "Authorization: Bearer $STUARTY_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "connection_id": "string",
  "model": "string",
  "project_id": "string",
  "prompt": "string"
}'

Response examples

{
  "actor": "string",
  "approval_id": "string",
  "created_at": "2006-01-02T15:04:05Z",
  "dry_run": false,
  "error": {
    "code": "string",
    "details": {},
    "hint": "string",
    "message": "string",
    "op_index": 0,
    "path": "string",
    "retryable": false
  },
  "estimate": {
    "currency": "string",
    "micros": 0
  },
  "finished_at": "2006-01-02T15:04:05Z",
  "job_id": "string",
  "kind": "string",
  "lint": {
    "errors": 0,
    "lint_scope": "string",
    "warnings": 0
  },
  "message": "string",
  "progress": 0,
  "project_id": "string",
  "result": {
    "batch": {
      "cancelled": 0,
      "failed": 0,
      "items": [],
      "succeeded": 0,
      "total": 0
    },
    "export": {
      "audio_codec": "string",
      "bytes": 0,
      "checks": [],
      "codec_fallback": "string",
      "download_url": "string",
      "duration": {},
      "format": "string",
      "fps": "string",
      "height": 0,
      "loudness_lufs": 0,
      "notes": [],
      "path": "string",
      "preset": "string",
      "revision": 0,
      "sha256": "string",
      "video_codec": "string",
      "width": 0
    },
    "face_track": {
      "asset_id": "string",
      "faces": 0,
      "fps": 0,
      "provider": "string",
      "samples": 0
    },
    "generated": {
      "cost": {},
      "delivered": 0,
      "image": {},
      "items": [],
      "model": "string",
      "notes": [],
      "provider": "string",
      "requested": 0
    },
    "image": {
      "bytes": 0,
      "format": "string",
      "height": 0,
      "image_id": "string",
      "job_id": "string",
      "path": "string",
      "revision": 0,
      "sha256": "string",
      "text": "string",
      "width": 0
    },
    "publish": {
      "connection_id": "string",
      "network": "string",
      "remote_id": "string",
      "state": "string",
      "thumbnail_error": "string",
      "url": "string"
    },
    "text": {
      "cost": {},
      "finish_reason": "string",
      "input_tokens": 0,
      "item_id": "string",
      "model": "string",
      "output_tokens": 0,
      "provider": "string",
      "revision": 0,
      "text": "string"
    },
    "transcribe": {
      "asset_id": "string",
      "language": "string",
      "words": 0
    }
  },
  "started_at": "2006-01-02T15:04:05Z",
  "state": "string",
  "text": "string",
  "warnings": [
    "string"
  ]
}

The examples are built from the schemas of the OpenAPI document, so a value is a placeholder of its type. The fields that carry the real values are in the tables.