# Chat with LLMs and make embeddings

> Chat Completions and embeddings in OpenAI's format, for every text model in the catalog, billed by the token.

`POST /chat/completions` and `POST /embeddings` follow OpenAI's format, so any OpenAI SDK works: change the base URL to `https://api.cut.pro/api/v1` and use your key. `model` is an `id` with `endpoint: chat_completions` or `embeddings` from [`GET /models`](/en/models).

```ts

const client = new OpenAI({ baseURL: "https://api.cut.pro/api/v1", apiKey: process.env.CUTPRO_API_KEY });

const answer = await client.chat.completions.create({
	model: "anthropic/claude-sonnet-5-5",
	messages: [{ role: "user", content: "Write three titles for a video about coffee." }],
});
```

```bash
curl -X POST https://api.cut.pro/api/v1/chat/completions \
  -H "X-Api-Key: $CUTPRO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "model": "deepseek/deepseek-v4.1-flash", "messages": [{ "role": "user", "content": "Hi!" }], "stream": true }'
```

- **Streaming**: with `stream: true`, the answer comes as server-sent events, as with OpenAI.
- **Reasoning effort**: `reasoning_effort` (`low`, `medium`, `high`) or `reasoning: { effort }`, on the models that list it in `supported_parameters`.
- **Tools, images and structured output**: `tools`, `image_url` parts in the messages and `response_format` go as you send them, where the model supports them.
- **Cost**: by the tokens read and written, at the prices of `GET /models`. Fractions of a credit add up and leave the balance as whole credits. A non-streamed answer reports its cost in `usage.credits`.

> The balance must cover the most the call can cost, counting the answer's `max_tokens` (or the model's limit, when left out). Without it the answer is `402 INSUFFICIENT_CREDITS`.

## Errors

| Code | When |
|---|---|
| `REQUEST_INVALID` | The body is not a valid request, or the model refused the fields sent. |
| `MODEL_UNAVAILABLE` | The model is not in the catalog or is not available right now. |
| `INSUFFICIENT_CREDITS` | Not enough balance. `extra.credits_needed` says how much the call needs. |
| `AI_UNAVAILABLE` | The model did not answer. Try again. |
