NexusAI Docs v2.0

NexusAI API

Dokumentacja REST API · v2.0.0

Base URL: https://api.nexusai.io/v2 | TLS 1.3 enforced | SLA 99.9%
SDK:

Szybki Start

Pierwsze zapytanie do API NexusAI w 2 minuty.

1. Pobierz klucz API

Przejdź do Dashboard → Klucze API i wygeneruj nowy klucz.

2. Pierwsze zapytanie
# Wyślij wiadomość do AI
curl https://api.nexusai.io/v2/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Tenant: twoj-slug" \
  -d '{
    "model": "gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}],
    "max_tokens": 256
  }'

Uwierzytelnianie

NexusAI używa kluczy API przekazywanych w nagłówku Authorization.

POST /auth/token Wymień credentials na JWT
Parametry body
emailrequiredstring
passwordrequiredstring
tenant_slugrequiredstring
Odpowiedź 200
{
  "access_token": "eyJ...",
  "expires_in": 3600,
  "token_type": "Bearer"
}

Chat Completions

Główny endpoint do komunikacji z modelami AI.

POST /chat/completions
Body Parameters
modelrequiredstringID modelu: gpt-4o, claude-3-opus, ...
messagesrequiredarrayTablica wiadomości [{role, content}]
max_tokensoptionalintegerLimit tokenów odpowiedzi (default: 1024)
temperatureoptionalnumberLosowość 0–2 (default: 1)
streamoptionalbooleanServer-sent events streaming
systemoptionalstringSystem prompt
top_poptionalnumberNucleus sampling 0–1
Request example
{
  "model": "gpt-4o",
  "messages": [
    {
      "role": "system",
      "content": "Jesteś asystentem."
    },
    {
      "role": "user",
      "content": "Pomóż mi napisać email"
    }
  ],
  "max_tokens": 512,
  "temperature": 0.7,
  "stream": false
}
Response 200
{
  "id": "chatcmpl-abc123",
  "model": "gpt-4o",
  "choices": [{
    "message": {
      "role": "assistant",
      "content": "Cześć! Jak mogę..."
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 24,
    "completion_tokens": 87,
    "total_tokens": 111
  }
}

Tenants API

Zarządzanie organizacjami (multi-tenancy).

GET/tenantsLista wszystkich tenantówsuperadmin
POST/tenantsUtwórz nowego tenantasuperadmin
GET/tenants/:idSzczegóły tenantasuperadmin
PATCH/tenants/:idAktualizuj tenantatenant_admin
DELETE/tenants/:idUsuń tenantasuperadmin
GET/tenants/:id/statsStatystyki tenantatenant_admin

Webhooks

Zdarzenia wysyłane do Twojego endpointu. Weryfikacja przez X-Nexus-Signature (HMAC-SHA256).

Dostępne zdarzenia
tenant.created
tenant.updated
tenant.deleted
user.created
user.login
ai.quota_exceeded
billing.payment_success
billing.payment_failed
webhook.test
integration.connected
Przykładowy payload zdarzenia
// POST https://twoja-domena.pl/webhook
{
  "event": "ai.quota_exceeded",
  "tenant": "twoj-slug",
  "timestamp": "2025-07-14T10:00:00Z",
  "data": {
    "used": 1000,
    "limit": 1000,
    "model": "gpt-4o"
  }
}

Rate Limits

Plan Req/min Req/dzień Tokeny/miesiąc Concurrent
Starter601 0001 000 0005
Business30010 00010 000 00020
Enterprise1 500100 000Unlimited100
Nagłówki odpowiedzi: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset. Po przekroczeniu limitu zwracamy 429 Too Many Requests.

Kody błędów

400Bad RequestNieprawidłowe parametry zapytania
401UnauthorizedBrak lub nieprawidłowy klucz API
403ForbiddenBrak uprawnień do zasobu
404Not FoundZasób nie istnieje
429Too Many RequestsPrzekroczono limit zapytań
500Internal Server ErrorBłąd po stronie serwera
503Service UnavailableBackend AI tymczasowo niedostępny

SDK & Biblioteki

Oficjalne SDK do integracji z NexusAI API.

🐍
Python SDK
pip install nexusai-python
v2.0.11.2k
🟡
JavaScript SDK
npm install @nexusai/sdk
v2.1.0890
🐘
PHP SDK
composer require nexusai/sdk
v1.5.0342
🦫
Go SDK
go get github.com/nexusai/go-sdk
v1.2.0567
Java SDK
maven: com.nexusai:sdk:2.0
v2.0.0234
💎
Ruby SDK
gem install nexusai
v1.3.0178
Narzędzia deweloperskie
API Playground →