Skip to content

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

MethodHeaderDescription
API KeyAuthorization: Bearer sk-...Platform signs x402 from your HD wallet automatically
Private Key (x402)Automatic via SDKAgent 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

python
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)
go
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)
}
bash
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

python
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)
go
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)
        }
    }
}
bash
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:

python
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

python
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"]
        }
    }]
)
go
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

python
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

ParameterTypeRequiredDescription
modelstringYesModel ID (e.g., anthropic/claude-sonnet-4.6)
inputstring or arrayYesText prompt or array of input items
streambooleanNoStream via SSE (default: false)
max_output_tokensintegerNoMaximum tokens to generate
temperaturenumberNoSampling temperature (0-2)
top_pnumberNoNucleus sampling
instructionsstringNoSystem-level instructions
toolsarrayNoTool definitions for function calling
tool_choicestring/objectNo"auto", "none", "required"
reasoningobjectNo{"effort": "low" | "medium" | "high"}
previous_response_idstringNoChain multi-turn conversations
storebooleanNoStore response for retrieval
metadataobjectNoArbitrary key-value pairs

Streaming Events

Event TypeDescription
response.createdResponse object created
response.in_progressProcessing started
response.output_item.addedNew output item started
response.content_part.addedNew content part started
response.output_text.deltaText chunk
response.content_part.doneContent part finished
response.output_item.doneOutput item finished
response.completedResponse 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:

json
{
  "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 formatFull output[] array with itemsFlat output_text string
MetadataFull (created_at, status, etc.)Minimal (id, model, usage, cost)
Tool callsIn output[] itemsIn tool_calls[] array (if any)
StreamingSupportedNot supported
Use caseGeneral purposeBatch/pipeline processing

Example:

python
response = client.post("/v1/responses/compact", json={
    "model": "openai/gpt-4.1-mini",
    "input": "Summarize this in one sentence: ..."
})
# response.json()["output_text"] → immediate result

See Also