AI

AI reference

Chat, embeddings, vision, OCR. Intent → provider routing handled for you.

Endpoints

MethodPathScopeDescription
POST/v1/ai/chatai:chatChat completion (sync).
POST/v1/ai/chat/streamai:chatChat completion (SSE stream).
POST/v1/ai/embedai:embeddingsGenerate embeddings.
POST/v1/ai/visionai:visionVision / OCR with structured output.

Quickstart

Try in playground →
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

CodeHTTPDescriptionResolution
E_AI_INTENT_DISABLED403Tenant disabled this intent (cost control).Enable at /ai/models or pick another intent.
E_AI_CONTEXT_TOO_LARGE413Combined prompt exceeded the provider context window.Trim history or chunk the input.