Rivya AI दस्तावेज़

Rivya API Quickstart

API key बनाएं, model चुनें, asynchronous generation job submit करें, और optional SSE streaming के साथ Chat API turn भेजें.

अंतिम समीक्षा 2026/05/10 को

यह quickstart account setup से एक Rivya API generation job तक सबसे छोटा सुरक्षित path दिखाता है, साथ में पहला Chat API turn भी।

Docs और examples में placeholder keys इस्तेमाल करें। Real API key को public code, screenshots, tickets या shared documents में कभी paste न करें।

1. API Key बनाएं

API Keys settings खोलें, key बनाएं, full secret को केवल एक बार copy करें, और उसे अपने server-side environment में store करें।

Recommended first scopes:

  • models:read
  • generations:create
  • generations:read
  • files:create
  • files:read
  • credits:read
  • webhooks:manage
  • chat:create
  • chat:read

2. अपना Base URL confirm करें

Production API base URL इस्तेमाल करें:

https://rivya.ai

Localhost URLs केवल local development के लिए हैं। Public examples में local secrets इस्तेमाल नहीं करने चाहिए।

3. Models list करें

curl https://rivya.ai/api/v1/models

generation create करते समय response के id field को model value के रूप में इस्तेमाल करें।

4. Generation submit करें

curl https://rivya.ai/api/v1/generations \
  -H "Authorization: Bearer rvya_sk_..." \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: quickstart-001" \
  -d '{
    "model": "z-image",
    "prompt": "A clean editorial product image on a soft studio background"
  }'

Response public task ID return करता है। इसे store करें ताकि बाद में status poll कर सकें।

5. Status poll करें

curl https://rivya.ai/api/v1/generations/task_public_id \
  -H "Authorization: Bearer rvya_sk_..."

Status values हैं:

  • queued
  • processing
  • succeeded
  • failed

6. Credits check करें

curl https://rivya.ai/api/v1/credits \
  -H "Authorization: Bearer rvya_sk_..."

Testing से पहले या बाद में current account balance confirm करने के लिए इसका इस्तेमाल करें।

7. Optional: Webhooks जोड़ें

अगर आपका server signed HTTPS callbacks receive कर सकता है, तो webhook endpoint create करें:

curl https://rivya.ai/api/v1/webhooks \
  -H "Authorization: Bearer rvya_sk_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production webhook",
    "url": "https://example.com/rivya/webhook",
    "event_types": ["generation.succeeded", "generation.failed"]
  }'

Response से one-time signing_secret save करें और payload पर भरोसा करने से पहले हर delivery verify करें।

8. Optional: Chat Turn भेजें

Chat models के लिए POST /api/v1/generations के बजाय Chat API call करें:

curl https://rivya.ai/api/v1/chat/completions \
  -H "Authorization: Bearer rvya_sk_..." \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: quickstart-chat-001" \
  -d '{
    "model": "gpt-5-2-chat",
    "message": "Write a concise launch plan for a new product image campaign"
  }'

API-created session जारी रखने के लिए returned session_id इस्तेमाल करें। Image attachments को Files API file_id values reference करनी चाहिए।

Optional: TypeScript SDK Beta इस्तेमाल करें

Server-side TypeScript integrations local SDK beta इस्तेमाल कर सकती हैं:

import { RivyaClient } from "@rivya/sdk";

const rivya = new RivyaClient({
  apiKey: process.env.RIVYA_API_KEY
});

const generation = await rivya.generations.create({
  model: "z-image",
  prompt: "A clean editorial product image on a soft studio background"
});

इसे अपनाने से पहले Rivya TypeScript SDK पढ़ें। SDK private beta में server-side Chat streaming support शामिल करता है।

अगले पेज

विषय-सूची