Responses API
The Responses API provides a simplified interface for generating AI responses, compatible with the OpenAI Responses format.
POST
/v1/responsesRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The model to use (e.g. "gpt-4o", "o3") |
input | string | array | Yes | Input text or array of message objects with role and content |
instructions | string | No | System instructions to guide the model's behavior |
max_output_tokens | integer | No | Maximum number of tokens to generate |
stream | boolean | No | If true, returns a stream of server-sent events. Default: false |
Request Example
curl https://api.osiris.ai/v1/responses \
-H "Authorization: Bearer sk-osiris-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"instructions": "You are a helpful assistant.",
"input": "What is the capital of France?"
}'Response Format
Response
{
"id": "resp_abc123",
"object": "response",
"created_at": 1712678400,
"model": "gpt-4o",
"status": "completed",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "The capital of France is Paris."
}
]
}
],
"usage": {
"input_tokens": 25,
"output_tokens": 12,
"total_tokens": 37
}
}Conversation Input
The input field can be a string for simple prompts, or an array of messages for multi-turn conversations:
Multi-turn conversation
{
"model": "gpt-4o",
"instructions": "You are a helpful assistant.",
"input": [
{ "role": "user", "content": "What is 2 + 2?" },
{ "role": "assistant", "content": "2 + 2 equals 4." },
{ "role": "user", "content": "And what is that times 3?" }
]
}SSE Event Types
When streaming is enabled, the API sends the following event types:
| Event | Description |
|---|---|
response.created | The response object has been created |
response.output_text.delta | A chunk of output text has been generated |
response.output_text.done | The output text generation is complete |
response.completed | The full response is complete with usage data |
Streaming Example
curl https://api.osiris.ai/v1/responses \
-H "Authorization: Bearer sk-osiris-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"stream": true,
"input": "Tell me a short joke."
}'The SSE stream will produce events in this format:
SSE stream format
event: response.created
data: {"type":"response.created","response":{"id":"resp_abc123","object":"response","status":"in_progress","model":"gpt-4o","output":[]}}
event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":"Why"}
event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":" did"}
event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":" the"}
event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":" chicken..."}
event: response.output_text.done
data: {"type":"response.output_text.done","text":"Why did the chicken cross the road? To get to the other side!"}
event: response.completed
data: {"type":"response.completed","response":{"id":"resp_abc123","object":"response","status":"completed","model":"gpt-4o","usage":{"input_tokens":10,"output_tokens":18,"total_tokens":28}}}