Responses API

The Responses API provides a stateful, high-level interface for interacting with LW AI models. It manages conversation state, supports tool use, and can execute multi-step agentic workflows in a single request.

POST https://openapi.linkwo.ai/v1/responses

Note: The Responses API is available for select models. Check Model Overview for compatibility.

Request Body

ParameterTypeRequiredDescription
modelstringYesModel ID
inputstring/arrayYesUser input or conversation history
instructionsstringNoSystem-level instructions
toolsarrayNoAvailable tools (web search, file search, code interpreter, functions)
tool_choicestring/objectNoTool selection mode
temperaturefloatNoSampling temperature (0–2)
max_output_tokensintegerNoMaximum output tokens
previous_response_idstringNoContinue from a previous response
streambooleanNoStream results via SSE

Example Request

curl https://openapi.linkwo.ai/v1/responses \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek/deepseek-v4-pro",
    "input": "What are the key differences between REST and GraphQL?"
  }'

Response

{
  "id": "resp_abc123",
  "object": "response",
  "created_at": 1719000000,
  "model": "deepseek/deepseek-v4-pro",
  "status": "completed",
  "output": [
    {
      "type": "message",
      "id": "msg_abc123",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "REST and GraphQL are two approaches to building APIs..."
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 15,
    "output_tokens": 200,
    "total_tokens": 215
  }
}
```bash

## Multi-Turn with previous_response_id

Pass `previous_response_id` to continue a conversation without resending the full history:

```python
from openai import OpenAI

client = OpenAI(
    base_url="https://openapi.linkwo.ai/v1",
    api_key="YOUR_API_KEY"
)

response_1 = client.responses.create(
    model="deepseek/deepseek-v4-pro",
    input="What is machine learning?"
)

response_2 = client.responses.create(
    model="deepseek/deepseek-v4-pro",
    input="How is it different from deep learning?",
    previous_response_id=response_1.id
)

Using Tools

The Responses API supports built-in tools and custom function calling:

response = client.responses.create(
    model="deepseek/deepseek-v4-pro",
    input="What's the weather in Beijing?",
    tools=[{
        "type": "function",
        "name": "get_weather",
        "description": "Get current weather for a location",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {"type": "string"}
            },
            "required": ["location"]
        }
    }]
)
```bash

## Related

- [Chat Completions](/docs/api-reference/chat-completions) — Lower-level API for chat
- [Function Calling](/docs/api-reference/function-calling) — Detailed tool usage guide