Docs

Create Response

POST/v1/responses

Creates a response using the OpenAI Responses API format

On this page
  1. Request Body
  2. Response
  3. Request Example
  4. Vision Input Example
  5. Response Example
  6. Error Response Example

Use Responses API when your application needs OpenAI Responses behavior. For most OpenAI-compatible clients, start with POST /v1/chat/completions.

Request Body

Parameter model

Type: string

Location: body

Required: yes

ID of the model to use. View available models in Console or with GET /v1/models.

Parameter input

Type: array

Location: body

Required: yes

A list of input items comprising the conversation.

Each item can be:

  • message: A conversation message with role and content
  • function_call: A function call request
  • function_call_output: Output from a function call

For multimodal input, message.content can be either a plain string or an array of content blocks. For image-capable models such as GPT-5.4 variants, pass images as input_image blocks instead of URLs or Base64 strings directly into plain text.

Example content blocks:

  • { "type": "input_text", "text": "Describe this image" }
  • { "type": "input_image", "image_url": "https://example.com/image.jpg" }
  • { "type": "input_image", "image_url": "data:image/png;base64,..." }

Parameter instructions

Type: string

Location: body

System instructions for the model (equivalent to system message).

Parameter max_output_tokens

Type: integer

Location: body

Maximum number of tokens to generate.

Parameter temperature

Type: number

Location: body

Sampling temperature between 0 and 2.

Parameter tools

Type: array

Location: body

A list of tools the model may call.

Parameter stream

Type: boolean

Location: body

If true, returns a stream of events.

Parameter previous_response_id

Type: string

Location: body

ID of a previous response to continue the conversation from.

Parameter store

Type: boolean

Location: body

Whether to store the response for later retrieval.

Parameter metadata

Type: object

Location: body

Metadata to attach to the response for tracking purposes.

Parameter text

Type: object

Location: body

Text generation configuration options. Behavior for text.format depends on the selected model and routed path; it is not guaranteed uniformly across every model.

Parameter parallel_tool_calls

Type: boolean

Location: body

Whether to allow multiple tool calls in parallel.

Parameter top_p

Type: number

Location: body

Nucleus sampling parameter (0-1).

Parameter reasoning

Type: object

Location: body

Reasoning configuration for reasoning-enabled models such as GPT-5 family variants.

  • effort (string): Reasoning effort level (low, medium, high)

Response

Response Field id

Type: string

Unique identifier for the response.

Response Field object

Type: string

Always response.

Response Field created

Type: integer

Unix timestamp of when the response was created.

Response Field output

Type: array

List of output items generated by the model.

Response Field usage

Type: object

Token usage statistics.

Request Example

curl -X POST "https://api.anypath.dev/v1/responses" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "input": [
      {"type": "message", "role": "user", "content": "Hello!"}
    ],
    "max_output_tokens": 1000
  }'
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-api-key",
    base_url="https://api.anypath.dev/v1"
)

response = client.responses.create(
    model="gpt-4o-mini",
    input=[
        {"type": "message", "role": "user", "content": "Hello!"}
    ],
    max_output_tokens=1000
)

print(response.output)
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'sk-your-api-key',
  baseURL: 'https://api.anypath.dev/v1'
});

const response = await client.responses.create({
  model: 'gpt-4o-mini',
  input: [
    { type: 'message', role: 'user', content: 'Hello!' }
  ],
  max_output_tokens: 1000
});

console.log(response.output);
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    payload := map[string]interface{}{
        "model": "gpt-4o-mini",
        "input": []map[string]interface{}{
            {"type": "message", "role": "user", "content": "Hello!"},
        },
        "max_output_tokens": 1000,
    }
    body, _ := json.Marshal(payload)

    req, _ := http.NewRequest("POST", "https://api.anypath.dev/v1/responses", bytes.NewBuffer(body))
    req.Header.Set("Authorization", "Bearer sk-your-api-key")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    var result map[string]interface{}
    json.NewDecoder(resp.Body).Decode(&result)
    fmt.Println(result["output"])
}
<?php
$ch = curl_init('https://api.anypath.dev/v1/responses');

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'Authorization: Bearer sk-your-api-key'
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'model' => 'gpt-4o-mini',
        'input' => [
            ['type' => 'message', 'role' => 'user', 'content' => 'Hello!']
        ],
        'max_output_tokens' => 1000
    ])
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
print_r($data['output']);

Vision Input Example

Use image-capable models by placing images inside message.content as input_image blocks. The image_url value can be either a public URL or a Base64 data URL.

{
  "model": "gpt-4o-mini",
  "input": [
    {
      "type": "message",
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "Please describe this image."
        },
        {
          "type": "input_image",
          "image_url": "https://example.com/demo.jpg"
        }
      ]
    }
  ]
}
{
  "model": "gpt-4o-mini",
  "input": [
    {
      "type": "message",
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "Please describe this image."
        },
        {
          "type": "input_image",
          "image_url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ..."
        }
      ]
    }
  ]
}

Response Example

{
  "id": "resp_abc123",
  "object": "response",
  "created": 1706000000,
  "model": "gpt-4o-mini",
  "output": [
    {
      "type": "message",
      "role": "assistant",
      "content": [
        {"type": "text", "text": "Hello! How can I help you today?"}
      ]
    }
  ],
  "usage": {
    "input_tokens": 10,
    "output_tokens": 12,
    "total_tokens": 22
  }
}

Error Response Example

{
  "error": {
    "message": "API key spending limit exceeded.",
    "type": "spending_limit_exceeded",
    "code": "spending_limit_exceeded"
  }
}