Generate text with OpenAI
openai_generate_textGenerate text with an OpenAI model through the Responses API and control output with system instructions, reasoning effort, JSON mode, and multi-turn chaining.
Instructions
Generate text with an OpenAI model through the Responses API — OpenAI's current interface for single-turn and chained generation.
Use this as the default text tool. It supports plain prompting, system instructions, reasoning effort control, forced JSON output and multi-turn chaining via previous_response_id.
Args:
input (string, required): the prompt
model (string): model ID, defaults to OPENAI_DEFAULT_TEXT_MODEL
instructions (string): system-level steering
max_output_tokens (number): 1-200000
temperature (number): 0-2
top_p (number): 0-1
reasoning_effort ('minimal'|'low'|'medium'|'high'): effort for reasoning models
json_object (boolean): force a valid JSON object as output (default false)
previous_response_id (string): continue an earlier stored response
store (boolean): persist the response for later chaining (default false)
response_format ('markdown'|'json'): default 'markdown'
Returns (JSON format): { "id": string, // response ID, usable as previous_response_id when store=true "model": string, // model that actually served the request "status": string | null, // e.g. "completed" or "incomplete" "output_text": string, // the generated text "usage": { "input_tokens": number|null, "output_tokens": number|null, "total_tokens": number|null } }
Examples:
Use when: "Summarise this contract clause" -> input=, instructions="Answer in German, max 3 sentences"
Use when: "Give me the result as JSON" -> json_object=true
Use when: continuing a stored conversation -> previous_response_id="resp_..."
Don't use when: you need to send an existing multi-message history verbatim (use openai_chat_completion)
Error Handling:
"Error: Not found" means the model ID does not exist for this key — call openai_list_models
"Error: Rate limit or quota exceeded" means retry later or lower the request rate
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | The prompt sent to the model | |
| model | No | Model ID, e.g. "gpt-5.6-sol". Defaults to OPENAI_DEFAULT_TEXT_MODEL. Call openai_list_models for the IDs this key can use. | |
| store | No | Persist the response on OpenAI servers so it can be referenced via previous_response_id | |
| top_p | No | Nucleus sampling cutoff; use either temperature or top_p, not both | |
| json_object | No | Force the model to emit a syntactically valid JSON object | |
| temperature | No | Sampling temperature, 0 = deterministic, 2 = very random | |
| instructions | No | System-level instructions that steer tone, role and constraints | |
| response_format | No | Output format: 'markdown' for a readable summary, 'json' for the full structured payload | markdown |
| reasoning_effort | No | How much internal reasoning a reasoning model should spend | |
| max_output_tokens | No | Upper bound on generated tokens | |
| previous_response_id | No | ID of a previous response to continue from; requires that the earlier call used store=true |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| model | Yes | ||
| usage | Yes | ||
| status | Yes | ||
| output_text | Yes |