Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions api/guides/text-generation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
description: "Generate text with the Liquid API: prompt a model, stream its reply, call tools, and get structured JSON output in a few lines of code."
---

Generate text with [`POST /openai/v1/chat/completions`](/api/reference/chat/chat-completions). It follows OpenAI's chat completions API, so the official OpenAI SDKs and most OpenAI-compatible frameworks work with the base URL `https://api.liquid.ai/openai/v1`.

Check warning on line 6 in api/guides/text-generation.mdx

View check run for this annotation

Mintlify / Mintlify Validation (liquidai) - vale-spellcheck

api/guides/text-generation.mdx#L6

Did you really mean 'SDKs'?

<CodeGroup>

Expand Down Expand Up @@ -70,16 +70,12 @@

`messages` is the conversation so far. A `system` message sets the model's behavior, `user` messages carry the prompts, and `assistant` messages carry the model's earlier replies. To continue a conversation, send the whole history again with the new user message at the end. The API keeps no conversation state between requests.

See [Chat template](/lfm/key-concepts/chat-template) and [Text generation and prompting](/lfm/key-concepts/text-generation-and-prompting) for how LFMs read a conversation and how to prompt them.

Check warning on line 73 in api/guides/text-generation.mdx

View check run for this annotation

Mintlify / Mintlify Validation (liquidai) - vale-spellcheck

api/guides/text-generation.mdx#L73

Did you really mean 'LFMs'?

## Sampling parameters

The API forwards OpenAI's chat parameters, such as `temperature`, `max_tokens`, and `stop`, to the model. It also forwards `top_k` and `repetition_penalty`, which are not part of OpenAI's API: in the Python SDK, pass them in `extra_body`.

<Warning>
`top_p` is not supported and returns `400`.
</Warning>

## Streaming

Set `stream` to `true` to receive the reply as server-sent events while the model generates it. Each chunk carries the next piece of text in `choices[0].delta.content`, and the final usage chunk carries `usage`.
Expand Down Expand Up @@ -133,7 +129,7 @@

## Tool calling

Pass OpenAI-style `tools` to let the model call functions you define. The model returns `tool_calls` in its message; run the functions yourself, send their results back as `tool` messages, and call the model again for its final answer. See [Tool use](/lfm/key-concepts/tool-use) for how LFMs format tool calls.

Check warning on line 132 in api/guides/text-generation.mdx

View check run for this annotation

Mintlify / Mintlify Validation (liquidai) - vale-spellcheck

api/guides/text-generation.mdx#L132

Did you really mean 'LFMs'?

```python
tools = [
Expand Down
2 changes: 1 addition & 1 deletion api/reference/error-codes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
description: "Liquid API error codes and HTTP status codes: what each error means, what causes it, and which errors are safe to retry."
---

Errors use OpenAI's shape, so the official SDKs raise their usual exceptions and retry the same responses they retry for OpenAI:

Check warning on line 6 in api/reference/error-codes.mdx

View check run for this annotation

Mintlify / Mintlify Validation (liquidai) - vale-spellcheck

api/reference/error-codes.mdx#L6

Did you really mean 'SDKs'?

```json
{
Expand All @@ -22,7 +22,7 @@

| Status | `type` | Cause | What to do |
| ------ | ------ | ----- | ---------- |
| `400` | `invalid_request_error` | The request body is invalid, for example a missing field, an unsupported parameter such as `top_p`, or an input type the model doesn't take. | Fix the field named in `param`. |
| `400` | `invalid_request_error` | The request body is invalid, for example a missing field, an unsupported parameter, or an input type the model doesn't take. | Fix the field named in `param`. |
| `401` | `authentication_error` | The API key is missing, invalid, or revoked (code `invalid_api_key`). | Send a valid key as `Authorization: Bearer $LIQUID_API_KEY`. |
| `402` | `insufficient_quota` | Your organization is not being served: it has no credit left and no card on file, or a payment failed (code `insufficient_quota`). | Add a card or settle the balance on the [Billing](https://console.liquid.ai/dashboard/billing) page. |
| `403` | `permission_error` | Your organization can't use this feature, for example the Batch API before it is enabled (code `batch_api_not_enabled`). | [Contact us](https://www.liquid.ai/connect) to request access. |
Expand All @@ -31,13 +31,13 @@
| `422` | `invalid_request_error` | A [decisions](/api/guides/decisions) request failed validation, for example a malformed question. | Fix the field named in `param`. |
| `429` | `rate_limit_error` | Your organization exceeded its request or token limit for the model (code `rate_limit_exceeded`). | Wait for `Retry-After`. See [Rate limits](/api/reference/rate-limits). |
| `499` | `api_error` | The client closed the connection before the response finished (code `client_closed_request`). | Nothing on our side; check your client's timeout. |
| `502` | `api_error` | The model's backend returned an error. | Retry with backoff. |

Check warning on line 34 in api/reference/error-codes.mdx

View check run for this annotation

Mintlify / Mintlify Validation (liquidai) - vale-spellcheck

api/reference/error-codes.mdx#L34

Did you really mean 'backoff'?
| `503` | `service_unavailable_error` | The model is at capacity or temporarily unavailable (code `server_is_overloaded`). | Wait for `Retry-After`, then retry. |
| `504` | `api_error` | The model's backend timed out (code `upstream_timeout`). | Retry, or stream the response for long generations. |

## Retrying

The official OpenAI SDKs retry `429`, `5xx`, and connection errors with exponential backoff. If you call the API directly, retry the same responses and honor `Retry-After` when it is present.

Check warning on line 40 in api/reference/error-codes.mdx

View check run for this annotation

Mintlify / Mintlify Validation (liquidai) - vale-spellcheck

api/reference/error-codes.mdx#L40

Did you really mean 'SDKs'?

Check warning on line 40 in api/reference/error-codes.mdx

View check run for this annotation

Mintlify / Mintlify Validation (liquidai) - vale-spellcheck

api/reference/error-codes.mdx#L40

Did you really mean 'backoff'?

<Warning>
Don't retry other `4xx` errors: they fail the same way every time.
Expand Down
Loading