POST /api/ai/generate
This public API endpoint allows you to generate text completions using supported AI models (e.g., Gemini). You must provide a valid access key for authentication.Endpoint
Request Body
Send a JSON object with the following fields:| Field | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | The prompt text to generate a completion for. |
accessKey | object | Yes | Your API access key object. Must include id and value fields. |
configs | object | No | (Optional) Configuration object for the request. See below for details. |
accessKey object
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Your API access ID. |
value | string | Yes | Your API access key. |
configs object
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
wsId | string | No | ROOT_WORKSPACE_ID | Workspace ID. |
model | string | No | ”gemini-2.0-flash” | The model to use (see Supported Models). Must be allowed for your key. |
systemPrompt | string | No | "" | (Optional) System instructions for the model. |
thinkingBudget | number | No | 0 | (Optional) Budget for model “thinking” (advanced). |
includeThoughts | boolean | No | false | (Optional) Include model “thoughts” in the response (advanced). |
Supported Models
gemini-2.0-flashgemini-2.0-flash-litegemini-2.5-flashgemini-2.5-flash-litegemini-2.5-pro
Example Request
Example Response
Errors
400 Missing accessKey— You must provide bothidandvaluein the accessKey object.400 Invalid model— The model is not allowed for your key.400 Invalid accessKey— The credentials are invalid.400 Missing prompt— The prompt field is required.400 Missing API key— Internal error, contact support.
Notes
- You must have a valid access key with the required model scope.
- The response includes the original input, the model output, token usage, cost breakdown, and the finish reason.