> ## 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.

# チャット補完

> C# SDKで/chat/completionsを呼び出します。

**メソッド**：`client.GenerateText(...)`または`client.CreateChatCompletion(...)`

### 例

```csharp theme={null}
using PhaseoSdk;

var client = new Phaseo(apiKey);
var response = await client.GenerateText(new Dictionary<string, object>
{
    ["model"] = "openai/gpt-5-nano",
    ["messages"] = new[]
    {
        new Dictionary<string, object>
        {
            ["role"] = "user",
            ["content"] = "Write a limerick about lighthouses."
        }
    }
});
```

### 主なパラメーター

* `model`（必須）：対象モデルのID。
* `messages`（必須）：`system|user|assistant|tool`のロールを持つ順序付きメッセージ。内容にはテキストまたはパーツを指定できます。
* サンプリング：`temperature`（0～2）、`top_p`（0～1）、`top_k`（>=1）、`seed`（整数、任意）。
* 長さとペナルティ：`max_output_tokens`（整数）、`presence_penalty`と`frequency_penalty`（-2～2）、`stop`（string|string\[]）。
* ツール：`tools`（定義）、`tool_choice`（auto/none/特定のツール）、`max_tool_calls`（整数）、`parallel_tool_calls`（boolean）。
* 対数確率：`logprobs`（boolean）、`top_logprobs`（0～20）。
* 出力：`response_format`（json/text）、`meta`（そのまま渡すオブジェクト）、`stream`（boolean）、`service_tier`。
* Gatewayの追加項目：`usage`（使用量を要求するboolean）、`meta`（metaブロックを含めるboolean）。

### 戻り値

`ChatCompletionsResponse`

```json theme={null}
{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "gpt-3.5-turbo-0125",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello there, how may I assist you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  }
}
```


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