AI reference
Chat, embeddings, vision, OCR. Intent → provider routing handled for you.
Endpoints
| Method | Path | Scope | Description |
|---|---|---|---|
| POST | /v1/ai/chat | ai:chat | Chat completion (sync). |
| POST | /v1/ai/chat/stream | ai:chat | Chat completion (SSE stream). |
| POST | /v1/ai/embed | ai:embeddings | Generate embeddings. |
| POST | /v1/ai/vision | ai:vision | Vision / OCR with structured output. |
Quickstart
curl -X POST https://api.valienz.io/v1/ai/chat \
-H "Authorization: Bearer $VALIENZ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini-class",
"messages": [{"role": "user", "content": "Hello"}]
}'Notes
Intent vs literal model
Prefer intents like `gpt-4o-mini-class` — they route to the cheapest healthy provider with that capability. Pass a literal `provider/model` (e.g. `openai/gpt-4o-mini`) only when you must.
Streaming
POST to /v1/ai/chat/stream with Accept: text/event-stream. The SDK exposes an async iterator over delta chunks; abort the stream via AbortController.
Errors
| Code | HTTP | Description | Resolution |
|---|---|---|---|
| E_AI_INTENT_DISABLED | 403 | Tenant disabled this intent (cost control). | Enable at /ai/models or pick another intent. |
| E_AI_CONTEXT_TOO_LARGE | 413 | Combined prompt exceeded the provider context window. | Trim history or chunk the input. |