मुख्य कंटेंट तक स्किप करें

Public API

Libre WebUI OpenAI-compatible API देता है, इसलिए मौजूदा SDK, editor और script को केवल base URL बदलना होता है।

Authentication

Settings → Account → API Tokens में scoped API token बनाएँ (lwk_ prefix, hash के रूप में stored)। /v1 के लिए chat scope चाहिए। Bearer scheme से token भेजें:

export OPENAI_BASE_URL="https://your-instance/v1"
export OPENAI_API_KEY="lwk_..."

सीमा token के लिए 600 requests प्रति minute है; shared chat limit भी लागू होती है।

Endpoints

Endpointउद्देश्य
GET /v1/modelsउपलब्ध local और provider models
POST /v1/chat/completionsStreaming या non-streaming stateless chat

POST /v1/chat/completions, model, messages (system/user/assistant), stream, temperature, top_p, max_tokens/max_completion_tokens, seed और stop स्वीकार करता है। Stream data: [DONE] तक SSE chat.completion.chunk भेजता है; non-streaming response में provider द्वारा reported usage होता है।

curl "$OPENAI_BASE_URL/chat/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "llama3.2",
"messages": [{"role": "user", "content": "One sentence on herons."}]
}'

जानबूझकर रखी गई सीमाएँ

/v1 stateless inference है: यह chats नहीं बनाता, knowledge base नहीं बदलता और tools नहीं चलाता। Stateful conversations, durable events, identity-bound cancellation, idempotent queue और native tool loop /api/chat में हैं, जो उसी token के chat scope से उपलब्ध है। system/user/assistant के अलावा tool जैसी roles reject होती हैं।

संबंधित दस्तावेज़