Let's build
something good.
From your first API key to your first response. The essentials, all in one place.
Quickstart
- Create an account and add credits in Billing.
- Generate a key from API keys. Copy it once and store it safely.
- Install the OpenAI SDK and make your first request.
npm install openaiimport OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.VIKI_API_KEY,
baseURL: "https://vikiapi.com/v1",
});
const response = await client.chat.completions.create({
model: "openai/gpt-6.1-sol",
messages: [{ role: "user", content: "Hello, Viki!" }],
max_tokens: 512,
});
console.log(response.choices[0].message.content);Authentication
Send your key in the Authorization header with every API request. Keep keys on your server. Never include them in client-side code or public repositories.
Authorization: Bearer YOUR_VIKI_API_KEYYou can create and revoke keys from your dashboard. A key is only displayed in full when you create it.
Text generation
/v1/chat/completionsUse an OpenAI-compatible request body. Choose a text model ID from the library, provide a messages array, and optionally set max_tokens and temperature. The initial API returns complete responses; streaming is not enabled.
curl https://vikiapi.com/v1/chat/completions \
-H "Authorization: Bearer $VIKI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-6.1-sol",
"messages": [{"role": "user", "content": "Write a haiku about possibility."}],
"max_tokens": 128
}'Image generation
/v1/images/generationsSubmit a model and prompt to create an image. Available resolution and aspect-ratio options depend on the model. The response includes the generated output.
curl https://vikiapi.com/v1/images/generations \
-H "Authorization: Bearer $VIKI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "black-forest-labs/flux-3-image",
"prompt": "A quiet architectural photograph of a sunlit courtyard"
}'Video generation
/v1/videosVideo generation runs asynchronously. Submit a prompt, save the returned job ID, and poll its status. Video requests can take several minutes to finish.
curl https://vikiapi.com/v1/videos \
-H "Authorization: Bearer $VIKI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "google/veo-3.1",
"prompt": "Soft morning light moving through a forest"
}'
# Poll with the job ID from the response
curl https://vikiapi.com/v1/videos/YOUR_JOB_ID \
-H "Authorization: Bearer $VIKI_API_KEY"Continue polling until the job completes or fails. Use the returned output URL when it is ready.
Model library
/v1/modelsRetrieve the available model IDs from the API, or browse the model library for descriptions and estimated provider rates. Different models support different generation settings.
Credits & billing
Viki uses a prepaid balance. Buy credits through Stripe in your dashboard. Model requests deduct actual provider usage plus the 20% platform fee. Estimated credits may be reserved while a request is running.
Video requests can keep a portion of your balance reserved while the job processes. Your dashboard separates available credits from pending reservations.
You can save a card securely with Stripe and opt into automatic top-ups in Billing. Choose the available-balance threshold, the amount to add, and a monthly limit. Automatic top-ups are off by default. Enabling them can trigger a charge if your available balance is already below the threshold. The monthly limit covers automatic top-ups initiated in each UTC calendar month, including payments still processing. Turn them off or remove your card at any time; a payment already processing may still complete.
If your bank declines a top-up or requires authentication, automatic top-ups pause. Update your card or complete a manual credit purchase, then explicitly enable automatic top-ups again. Requests still require enough available credits while a payment is pending.
View pricingWhen something goes wrong
| Status | Meaning | Next step |
|---|---|---|
| 400 | Invalid request | Check the model and required fields. |
| 401 | Not authenticated | Check your API key. |
| 402 | Not enough credits | Add credits or wait for pending requests. |
| 429 | Rate limited | Wait briefly, then retry. |
| 502 / 503 | Provider unavailable | Try again later or choose another model. |
Responses include an error message describing the issue. Failed requests are recorded so you can see what happened in your usage history.