# Chat

URL: https://docs.hanzo.ai/docs/guides/chat

> One completion.

**One completion.**

> POST /v1/chat/completions, the gateway's own inference route. The id lost its `v1` when the default version left the operationId; the address did not move.

The document states that address and NOT its shape — no requestBody and no responses — so a generated method takes no prompt and hands back an opaque body. No language can ship this as an example that runs, and python, typescript and go each ship five. The flow keeps its place here because the operation is served: the day cloud's handler declares its In and Out types, the sixth example returns everywhere at once with nothing left to decide.

Non-streaming when it does. Streaming is a different transport (SSE) that the generated clients return as an opaque body, so demonstrating it here would teach the wrong shape. Print choices\[0].message.content.

## Implements the OpenAI-compatible chat completions API

`POST /v1/chat/completions` · [reference →](https://docs.hanzo.ai/docs/openapi/ai)

Implements the OpenAI-compatible chat completions API

| Parameter               | In     | Required | Description                                                                                                    |
| ----------------------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------- |
| `X-Max-Cost`            | header | —        | The most this request may cost, in USD per 1,000 tokens. Routing picks only models under it; an org's own ceil |
| `X-Max-Latency-Ms`      | header | —        | The slowest model this request accepts, in milliseconds.                                                       |
| `frequency_penalty`     | body   | —        |                                                                                                                |
| `function_call`         | body   | —        |                                                                                                                |
| `functions`             | body   | —        |                                                                                                                |
| `logit_bias`            | body   | —        |                                                                                                                |
| `logprobs`              | body   | —        |                                                                                                                |
| `max_completion_tokens` | body   | —        |                                                                                                                |
| `max_tokens`            | body   | —        |                                                                                                                |
| `messages`              | body   | —        |                                                                                                                |
| `metadata`              | body   | —        |                                                                                                                |
| `model`                 | body   | —        |                                                                                                                |
| `n`                     | body   | —        |                                                                                                                |
| `parallel_tool_calls`   | body   | —        |                                                                                                                |

**CLI**

```bash
hanzo chat completions
```

**SDK**

**.ts**

```ts
import { Configuration, AiApi } from 'hanzoai';

const api = new AiApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postChatCompletions({ frequency_penalty: 0, function_call: "<function_call>" });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import AiApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = AiApi(client).post_chat_completions(frequency_penalty=0, function_call="<function_call>")
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.AiAPI.PostChatCompletions(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, ai_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = ai_api::post_chat_completions(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.AiApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new AiApi(client).postChatCompletions();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/chat/completions \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "frequency_penalty": 0,
       "function_call": "<function_call>"
     }'
```

**MCP**

MCP declares no tool for **ai** — `tools/list` on `https://api.hanzo.ai/v1/mcp` names the products it does reach. Use HTTP or an SDK.

---

Every command, call and tool above is generated from the same OpenAPI document that generates the SDKs themselves — the four surfaces are projections of one doc comment, so they cannot disagree.
