---
title: "Generate AI chat response"
method: POST
path: "/ai/chat"
tags: ["ai"]
---

# Generate AI chat response

`POST /ai/chat`

Chat with AI via Anthropic, Open Router, or Ollama. Set ANTHROPIC_API_KEY, OPEN_ROUTER_API_KEY, or OLLAMA_BASE_URL. Default model configurable via AI_DEFAULT_MODEL. Supports streaming and tools.

## Request body

- object
  - `messages` union[], required
    - union
      - object
        - `role` string, required
        - `content` string, required
        - `name` string
      - object
        - `role` string, required
        - `parts` unknown[], required
          - unknown
  - `stream` boolean
  - `model` string
  - `temperature` number
  - `tools` unknown

## Response `200`

Chat response (JSON) or streaming (SSE)

- object
  - `text` string, required

## Other responses

- `400` — Default Response
- `401` — Default Response
- `402` — Default Response
- `500` — Default Response
- `502` — Default Response

## Changes

> 4 revisions in range; 1 could not be searched.

- **2026-01-15** `c4ddc6be4535` — 4 breaking, 1 info
  - removed the enum value `assistant` of the request property `messages/items/role`
  - removed the enum value `system` of the request property `messages/items/role`
  - removed the enum value `user` of the request property `messages/items/role`
  - the `messages/items/role` request property type/format changed from `string`/`` to ``/``
  - …1 more
- **2026-01-15** `8e8d1be8bbf2` — 1 info
  - endpoint added
- **2026-01-14** `4f6c72308c7a` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/blockmatic/apis/basilic-api/changes/ai/chat/post.md)

---

[API](https://skmtc.dev/blockmatic/apis/basilic-api.md) · [All operations](https://skmtc.dev/blockmatic/apis/basilic-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/blockmatic/basilic-api/revisions/b2c23a2d8170/schema)
