# Z.AI (/docs/providers/zai)


## Overview [#overview]

Z.AI provides professional-grade AI models with native multimodal capabilities. Through Yunxin, Z.AI models are accessed via the Chat Completions API format.

**Official Website:** [https://docs.z.ai](https://docs.z.ai)

## Key Features [#key-features]

* **Multimodal Input** — Native support for text, images (`image_url`), videos (`video_url`), and documents (`file_url`)
* **Thinking/Reasoning** — Extended reasoning support via `thinking` parameter
* **Function Calling** — Full tool use support
* **Structured Output** — JSON and structured responses via `response_format`
* **Streaming** — Server-sent events for real-time responses

## Usage Example [#usage-example]

```python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.yuhuanstudio.com/v1"
)

response = client.chat.completions.create(
    model="model-id",
    messages=[{"role": "user", "content": "Hello!"}]
)

print(response.choices[0].message.content)
```

## Multimodal Content [#multimodal-content]

Z.AI natively supports multiple content types in the Chat Completions format:

### Images [#images]

```json
{
  "type": "image_url",
  "image_url": {"url": "https://example.com/photo.jpg"}
}
```

### Documents [#documents]

```json
{
  "type": "file_url",
  "file_url": {"url": "https://example.com/document.pdf"}
}
```

### Videos [#videos]

```json
{
  "type": "video_url",
  "video_url": {"url": "https://example.com/video.mp4"}
}
```

## Thinking/Reasoning [#thinkingreasoning]

Enable extended reasoning for complex tasks:

```python
response = client.chat.completions.create(
    model="model-id",
    messages=[{"role": "user", "content": "Solve this complex problem..."}],
    extra_body={"thinking": {"type": "enabled"}}
)
```

## Function Calling [#function-calling]

```python
response = client.chat.completions.create(
    model="model-id",
    messages=[{"role": "user", "content": "What's the weather?"}],
    tools=[{
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get current weather",
            "parameters": {
                "type": "object",
                "properties": {"location": {"type": "string"}},
                "required": ["location"]
            }
        }
    }]
)
```

## Available Models [#available-models]

Use the [Models API](/docs/models-api) to query available models:

```bash
curl https://api.yuhuanstudio.com/v1/models?provider=zai \
  -H "Authorization: Bearer YOUR_API_KEY"
```

<Callout type="info">
  Models and pricing are synced automatically. Check the dashboard for current availability and rates.
</Callout>

## Official Resources [#official-resources]

* [Z.AI Documentation](https://docs.z.ai)
* [API Reference](https://docs.z.ai/api)
