> ## Documentation Index
> Fetch the complete documentation index at: https://phaseo.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Responses API

> TypeScript SDKでResponses APIを呼び出します。

**メソッド**: `client.generateResponse()` (パース済みチャンクをストリーミングするには `client.streamResponses()`).

### 例

```typescript theme={null}
const resp = await client.generateResponse({
  model: "openai/gpt-4.1",
  input: [{ role: "user", content: [{ type: "input_text", text: "Summarise this text" }] }],
  temperature: 0.7,
  stream: false,
});
```

### ストリーミング

```typescript theme={null}
for await (const chunk of client.streamResponses({
  model: "openai/gpt-4.1",
  input: [{ role: "user", content: [{ type: "input_text", text: "Stream this" }] }],
  stream: true,
})) {
  if (chunk.text) process.stdout.write(chunk.text);
}
```

### 主なパラメーター

* `model` (required): 対象モデルのID。
* `input` (required): 入力項目（メッセージ、ツール呼び出しなど）の順序付き配列です。
* `temperature` (0-2): 値を大きくするとランダム性が高まります。
* `top_p` (0-1) / `top_k` (>=1): Nucleus / k-bestサンプリングの設定です。
* `max_output_tokens` (int): 応答ごとに生成するトークン数の上限です。
* ツール： `tools` (定義), `tool_choice` (`auto`/`none`/指定), `max_tool_calls` (int), `parallel_tool_calls` (bool).
* Logprobs： `logprobs` (bool), `top_logprobs` (0-20) トークンごとのlogprobを返します。
* 出力： `response_format` (json/text), `service_tier`, `store` (bool), `stream` (bool).
* メタデータ： `metadata` (object) そのまま引き渡すデータ, `reasoning` (object) 推論の強さのヒント.
* Gateway固有の追加項目： `usage` (bool 使用量を要求する), `meta` (bool metaブロックを含める).

### 戻り値

`ResponsesResponse`

```json theme={null}
{
  "id": "resp_123",
  "object": "response",
  "created_at": 1677652288,
  "status": "completed",
  "model": "gpt-4.1",
  "output": [
    {
      "type": "message",
      "id": "msg_123",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "Hello there, how may I assist you today?"
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 9,
    "output_tokens": 12,
    "total_tokens": 21
  }
}
```

`stream: true`の場合は改行区切りのSSEフレームが返されます。

```
data: {"id":"resp_123","object":"response","created_at":1677652288,"status":"in_progress","model":"gpt-4.1","output":[{"type":"message","id":"msg_123","status":"in_progress","role":"assistant","content":[]}]}

data: {"id":"resp_123","object":"response","created_at":1677652288,"status":"in_progress","model":"gpt-4.1","output":[{"type":"message","id":"msg_123","status":"in_progress","role":"assistant","content":[{"type":"output_text","text":"Hello"}]}]}

data: {"id":"resp_123","object":"response","created_at":1677652288,"status":"completed","model":"gpt-4.1","output":[{"type":"message","id":"msg_123","status":"completed","role":"assistant","content":[{"type":"output_text","text":"Hello there, how may I assist you today?"}]}],"usage":{"input_tokens":9,"output_tokens":12,"total_tokens":21}}

data: [DONE]
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.