Responses API
OpenAI Responses API — the next-generation replacement for Chat Completions. Supports streaming, function calling, extended thinking, and multi-turn via previous_response_id. Compatible with the official openai Python SDK and openai-go SDK.
Base URL: https://api.jarvisclaw.ai/v1
Authentication
| Method | Header | Description |
|---|---|---|
| API Key | Authorization: Bearer sk-... | Platform signs x402 from your HD wallet automatically |
| Private Key (x402) | Automatic via SDK | Agent signs x402 directly from its own wallet |
See Agent Payments (x402) for full details.
Endpoint
POST /v1/responses
Create a model response. The platform routes to Claude, GPT, or Gemini upstream with automatic format conversion.
Quick Start
from openai import OpenAI
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://api.jarvisclaw.ai/v1"
)
# Simple text response
response = client.responses.create(
model="anthropic/claude-sonnet-4.6",
input="Explain quantum computing in one paragraph"
)
print(response.output_text)package main
import (
"context"
"fmt"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("sk-your-api-key"),
option.WithBaseURL("https://api.jarvisclaw.ai/v1"),
)
resp, _ := client.Responses.New(context.Background(),
openai.ResponseNewParams{
Model: "anthropic/claude-sonnet-4.6",
Input: openai.ResponseNewParamsInputUnionString(
"Explain quantum computing in one paragraph",
),
},
)
fmt.Println(resp.OutputText)
}curl https://api.jarvisclaw.ai/v1/responses \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4.6",
"input": "Explain quantum computing in one paragraph"
}'Streaming
from openai import OpenAI
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://api.jarvisclaw.ai/v1"
)
stream = client.responses.create(
model="anthropic/claude-sonnet-4.6",
input="Write a short story about an AI agent",
stream=True
)
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)package main
import (
"context"
"fmt"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
"github.com/openai/openai-go/responses"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("sk-your-api-key"),
option.WithBaseURL("https://api.jarvisclaw.ai/v1"),
)
stream := client.Responses.NewStreaming(context.Background(),
openai.ResponseNewParams{
Model: "anthropic/claude-sonnet-4.6",
Input: openai.ResponseNewParamsInputUnionString(
"Write a short story about an AI agent",
),
},
)
defer stream.Close()
for stream.Next() {
evt := stream.Current()
switch evt := evt.AsAny().(type) {
case responses.ResponseTextDeltaEvent:
fmt.Print(evt.Delta)
}
}
}curl https://api.jarvisclaw.ai/v1/responses \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4.6",
"input": "Write a short story about an AI agent",
"stream": true
}'Multi-turn Conversations
Use previous_response_id to chain turns without resending full history:
resp1 = client.responses.create(
model="anthropic/claude-sonnet-4.6",
input="What is the capital of France?"
)
resp2 = client.responses.create(
model="anthropic/claude-sonnet-4.6",
input=[{"role": "user", "content": [{"type": "input_text", "text": "And what about Germany?"}]}],
previous_response_id=resp1.id
)Function Calling
response = client.responses.create(
model="anthropic/claude-sonnet-4.6",
input=[{"role": "user", "content": [{"type": "input_text", "text": "What's the weather in Tokyo?"}]}],
tools=[{
"type": "function",
"name": "get_weather",
"description": "Get current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"}
},
"required": ["location"]
}
}]
)resp, _ := client.Responses.New(ctx, openai.ResponseNewParams{
Model: "anthropic/claude-sonnet-4.6",
Input: openai.ResponseNewParamsInputUnion(openai.ResponseNewParamsInputItemList{
{Role: "user", Content: []openai.ContentPart{{Type: "input_text", Text: "What's the weather in Tokyo?"}}},
}),
Tools: []openai.ToolUnion{{
Type: "function",
Function: &openai.FunctionTool{
Name: "get_weather",
Description: "Get current weather for a location",
Parameters: map[string]any{
"type": "object",
"properties": map[string]any{"location": map[string]any{"type": "string"}},
"required": []string{"location"},
},
},
}},
})Extended Thinking / Reasoning
response = client.responses.create(
model="anthropic/claude-sonnet-4.6",
input="Solve step by step: what is the 100th prime number?",
reasoning={"effort": "high"}
)Reasoning content appears as reasoning type content in output items when streaming.
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model ID (e.g., anthropic/claude-sonnet-4.6) |
| input | string or array | Yes | Text prompt or array of input items |
| stream | boolean | No | Stream via SSE (default: false) |
| max_output_tokens | integer | No | Maximum tokens to generate |
| temperature | number | No | Sampling temperature (0-2) |
| top_p | number | No | Nucleus sampling |
| instructions | string | No | System-level instructions |
| tools | array | No | Tool definitions for function calling |
| tool_choice | string/object | No | "auto", "none", "required" |
| reasoning | object | No | {"effort": "low" | "medium" | "high"} |
| previous_response_id | string | No | Chain multi-turn conversations |
| store | boolean | No | Store response for retrieval |
| metadata | object | No | Arbitrary key-value pairs |
Streaming Events
| Event Type | Description |
|---|---|
response.created | Response object created |
response.in_progress | Processing started |
response.output_item.added | New output item started |
response.content_part.added | New content part started |
response.output_text.delta | Text chunk |
response.content_part.done | Content part finished |
response.output_item.done | Output item finished |
response.completed | Response completed with usage |
Compact Responses
POST /v1/responses/compact
A lightweight variant that returns only the essential fields — useful for high-throughput pipelines where you don't need full metadata.
Request: Same as /v1/responses — all body parameters are identical.
Response: Stripped-down output with only the text/tool results:
{
"id": "resp_abc123",
"output_text": "The 100th prime number is 541.",
"usage": {
"input_tokens": 42,
"output_tokens": 18,
"total_tokens": 60
},
"model": "anthropic/claude-sonnet-4.6",
"cost_usd": 0.0003
}Key differences from full /v1/responses:
| Aspect | /v1/responses | /v1/responses/compact |
|---|---|---|
| Output format | Full output[] array with items | Flat output_text string |
| Metadata | Full (created_at, status, etc.) | Minimal (id, model, usage, cost) |
| Tool calls | In output[] items | In tool_calls[] array (if any) |
| Streaming | Supported | Not supported |
| Use case | General purpose | Batch/pipeline processing |
Example:
response = client.post("/v1/responses/compact", json={
"model": "openai/gpt-4.1-mini",
"input": "Summarize this in one sentence: ..."
})
# response.json()["output_text"] → immediate resultSee Also
- Anthropic Messages API — Native Anthropic protocol (use
anthropicSDK directly) - Chat Completions API — Legacy OpenAI Chat format
- Models — Full model list