Skip to main content
POST
/
api
/
v1
/
responses
curl --request POST \
  --url https://api.crun.ai/api/v1/responses \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "gpt-5.4",
  "instructions": "You are a concise product copywriter.",
  "input": "Write a one-sentence launch caption for a noise-canceling headset.",
  "temperature": 0.7
}
'
{
  "id": "resp_abc123",
  "object": "response",
  "created_at": 1772294400,
  "status": "completed",
  "model": "gpt-5.4",
  "output": [
    {
      "id": "msg_abc123",
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "Launch focus anywhere with a headset that quiets distractions and keeps calls crisp."
        }
      ]
    }
  ],
  "output_text": "Launch focus anywhere with a headset that quiets distractions and keeps calls crisp.",
  "usage": {
    "input_tokens": 18,
    "output_tokens": 14,
    "total_tokens": 32
  }
}

API Endpoint

POST https://api.crun.ai/api/v1/responses
The Responses API is OpenAI’s newer model interface for text and image inputs, text outputs, stateful follow-ups, structured outputs, and tool-using workflows. This endpoint follows the OpenAI Response request and response format. It is designed for direct use with the official OpenAI SDKs and other OpenAI-compatible clients.

Authentication

You can authenticate with either:
  • Authorization: Bearer YOUR_API_KEY
  • X-API-KEY: YOUR_API_KEY

When to Use Responses

Use /responses when you want:
  • Top-level instructions instead of a system message.
  • A flexible input field that can be a string or a list of message-like items.
  • Stateful follow-ups with previous_response_id when the upstream model supports stored responses.
  • Structured outputs through text.format.
  • Tool-ready response items and tools / tool_choice fields.
Use /chat/completions when you need the classic messages -> choices[] -> message shape for an existing chat integration.

Basic Text Generation

curl -X POST "https://api.crun.ai/api/v1/responses" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "instructions": "You are a concise product copywriter.",
    "input": "Write a one-sentence launch caption for a noise-canceling headset.",
    "temperature": 0.7
  }'

Message-Style Input

The input field can also contain a list of message-like items, which makes migration from Chat Completions straightforward.
curl -X POST "https://api.crun.ai/api/v1/responses" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "input": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Explain prompt caching in two short bullet points."
      }
    ]
  }'

Image Input

When the selected model supports vision, pass images in the content array with type: "input_image". You can use a public image URL, a Base64 data URL for vision.
curl -X POST "https://api.crun.ai/api/v1/responses" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "input": [
      {
        "role": "user",
        "content": [
          {
            "type": "input_text",
            "text": "Describe this image in one paragraph."
          },
          {
            "type": "input_image",
            "image_url": "https://example.com/product-photo.jpg"
          }
        ]
      }
    ]
  }'

File Input

For PDFs and other uploaded files supported by the upstream model, upload the file first and pass it as an input_file content part.
curl -X POST "https://api.crun.ai/api/v1/responses" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "input": [
      {
        "role": "user",
        "content": [
          {
            "type": "input_text",
            "text": "what is in this file?"
          },
          {
            "type": "input_file",
            "file_url": "https://www.berkshirehathaway.com/letters/2024ltr.pdf"
          }
        ]
      }
    ]
  }'

Stateful Follow-Up

When the upstream model supports stored responses, set store=true and pass previous_response_id to continue from a previous response without resending all context.
curl -X POST "https://api.crun.ai/api/v1/responses" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "input": "Give me three naming ideas for a developer newsletter.",
    "store": true
  }'

curl -X POST "https://api.crun.ai/api/v1/responses" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"input": "Make the names more playful.",
"previous_response_id": "resp_abc123",
"store": true
}'

Structured Output

For Responses, structured output uses text.format. This differs from Chat Completions, where the equivalent field is response_format.
curl -X POST "https://api.crun.ai/api/v1/responses" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "input": "Extract a task from: Maya should send the launch brief by Friday.",
    "text": {
      "format": {
        "type": "json_schema",
        "name": "task",
        "strict": true,
        "schema": {
          "type": "object",
          "properties": {
            "owner": { "type": "string" },
            "task": { "type": "string" },
            "due": { "type": "string" }
          },
          "required": ["owner", "task", "due"],
          "additionalProperties": false
        }
      }
    }
  }'

Tool-Ready Request

OpenAI’s Responses API supports built-in tools and function-style tools. CRUN accepts compatible tools and tool_choice fields and forwards them when the selected upstream model supports them.
tool request
{
  "model": "gpt-5.4",
  "input": "Search my connected knowledge base and summarize our refund policy.",
  "tools": [
    {
      "type": "file_search",
      "vector_store_ids": [
        "vs_123"
      ]
    }
  ],
  "tool_choice": "auto"
}

Streaming

Set stream=true to receive Server-Sent Events from /responses. Each event includes an event: line followed by a JSON data: payload.
curl -N "https://api.crun.ai/api/v1/responses" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "instructions": "You are a concise assistant.",
    "input": "Write a three-step checklist for reviewing an API integration.",
    "stream": true
  }'

Response Examples

{
  "id": "resp_abc123",
  "object": "response",
  "created_at": 1772294400,
  "status": "completed",
  "model": "gpt-5.4",
  "output": [
    {
      "id": "msg_abc123",
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "Launch focus anywhere with a headset that quiets distractions and keeps calls crisp."
        }
      ]
    }
  ],
  "output_text": "Launch focus anywhere with a headset that quiets distractions and keeps calls crisp.",
  "usage": {
    "input_tokens": 18,
    "output_tokens": 14,
    "total_tokens": 32
  }
}

Notes

  • max_output_tokens is capped by the selected model’s output token limit.
  • Additional OpenAI-compatible fields are accepted and passed through when supported by the upstream model.
  • Structured outputs use text.format; Chat Completions uses response_format.
  • Tool availability depends on the selected model and upstream provider.
  • Unknown model IDs return an OpenAI-style error body with code: "model_not_found".

LLM Quickstart

Learn the base URL, authentication method, and official SDK integration pattern.

Chat Completions API

Use the classic messages and choices API for existing chat clients.

Pricing

Jump to the pricing page to compare billing across different models.

Authorizations

Authorization
string
header
required

Use your CRUN API key as a Bearer token for OpenAI-compatible SDKs.

Body

application/json

OpenAI-compatible Responses request. Additional compatible fields are accepted and passed through when supported by the upstream model.

model
string
required

Public model ID returned by GET /api/v1/models.

Required string length: 1 - 128
Example:

"gpt-5.4"

input

Model input. Can be a string or a list of response input items; supports text, image, and file content parts depending on the selected model and upstream provider.

Example:

"Write a one-sentence launch caption for a noise-canceling headset."

instructions

System or developer instructions for the model.

Example:

"You are a concise product copywriter."

stream
boolean
default:false

Whether to return a Server-Sent Events stream.

Example:

false

store
boolean

Whether the upstream provider should store the response for stateful follow-ups, when supported.

Example:

true

previous_response_id
string

ID of a previous stored response to continue from, when supported.

Example:

"resp_abc123"

metadata
object

Developer-defined metadata.

max_output_tokens
integer

Maximum output tokens. Capped by the selected model.

Required range: x >= 1
Example:

512

temperature
number

Sampling temperature.

Required range: 0 <= x <= 2
Example:

0.7

top_p
number

Nucleus sampling value.

Required range: 0 <= x <= 1
Example:

1

user
string

End-user identifier passed for observability.

Example:

"user_123"

prompt_cache_key
string

Prompt cache key passed to the upstream provider when supported.

prompt_cache_retention
enum<string>

Prompt cache retention policy when supported.

Available options:
in-memory,
24h
reasoning
object

Reasoning model configuration.

Example:
{ "effort": "medium" }
text
object

Text output configuration. Use text.format for structured outputs in the Responses API.

Example:
{ "format": { "type": "json_object" } }
tools
object[]

Tool definitions in OpenAI-compatible Responses format.

tool_choice

Tool selection strategy.

Example:

"auto"

parallel_tool_calls
boolean

Whether to allow parallel tool calls when supported.

Example:

true

truncation
string

Context truncation strategy when supported.

Example:

"auto"

Response

Successful response. Returns JSON when stream=false, or SSE when stream=true.

id
string
Example:

"resp_abc123"

object
string
Example:

"response"

created_at
integer

Unix timestamp in seconds.

Example:

1772294400

status
string
Example:

"completed"

model
string

Public model ID requested by the client.

Example:

"gpt-5.4"

output
object[]
output_text
string

Convenience text field when provided by the upstream provider.

Example:

"Launch focus anywhere with a headset that quiets distractions and keeps calls crisp."

usage
object