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

# チャット補完

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

**メソッド**: `client.generate_text(...)`、`client.create_chat_completion(...)`。

### 例

```ruby theme={null}
require 'phaseo_sdk'

client = PhaseoSdk::Phaseo.new(api_key: ENV.fetch("PHASEO_API_KEY"))

response = client.create_chat_completion(
  "model" => "openai/gpt-4o-mini",
  messages: [
    { "role" => "user", "content" => "Write a limerick about lighthouses." }
  ],
  "temperature" => 0.5
)
```

### 主なパラメーター

* `model`（必須）：対象モデルのID。
* `messages`（必須）：`user`/`system`/`assistant`/`tool`ロールを持つ順序付きメッセージ。内容は文字列です。
* サンプリング：`temperature`（0～2）、`top_p`（0～1）、`top_k`（>=1）、`seed`（整数、任意）。
* 長さ/ペナルティ：`max_output_tokens`（整数）、`presence_penalty`と`frequency_penalty`（-2～2）、`stop`（文字列または文字列配列）。
* ツール：`tools`（定義）、`tool_choice`（自動/なし/特定ツール）、`max_tool_calls`（整数）、`parallel_tool_calls`（真偽値）。
* 対数確率：`logprobs`（真偽値）、`top_logprobs`（0～20）。
* 出力：`response_format`（json/text）、`metadata`（そのまま渡されるオブジェクト）、`stream`（真偽値）、`service_tier`。
* ゲートウェイ追加項目：`usage`（使用量を要求する真偽値）、`meta`（metaブロックを含める真偽値）。

### 戻り値

`ChatCompletionsResponse`


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