### Example API Request for GPT-5.4 Mini Source: https://nexusapilabs.com/docs/models/gpt-5.4-mini This snippet shows how to make a POST request to the Nexus API to get a completion from the gpt-5.4-mini model. Ensure you have your API key set as an environment variable. ```bash curl -X POST https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.4-mini", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` -------------------------------- ### Example API Request for GPT-4o Mini Source: https://nexusapilabs.com/docs/models/gpt-4o-mini This snippet shows how to make a POST request to the Nexus API to get a completion from the GPT-4o Mini model. Ensure your API key is set as an environment variable. ```bash curl -X POST https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o-mini", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` -------------------------------- ### Install Node.js OpenAI SDK Source: https://nexusapilabs.com/docs/sdks Install the official OpenAI Node.js library to interact with Nexus AI. ```bash npm install openai ``` -------------------------------- ### Install PHP OpenAI Client Source: https://nexusapilabs.com/docs/sdks Install the openai-php/client package using Composer to interact with Nexus AI. ```bash composer require openai-php/client ``` -------------------------------- ### Install Python OpenAI SDK Source: https://nexusapilabs.com/docs/sdks Install the official OpenAI Python library to interact with Nexus AI. ```bash pip install openai ``` -------------------------------- ### Example Pagination Request Source: https://nexusapilabs.com/docs/rate-limits Demonstrates how to use limit and offset parameters to paginate through list endpoints like transactions or usage data. ```HTTP GET /v1/billing/transactions?limit=20&offset=40 ``` -------------------------------- ### Example API Request for GPT-4.1 Nano Source: https://nexusapilabs.com/docs/models/gpt-4.1-nano This snippet demonstrates how to make a POST request to the Nexus API Labs endpoint to get a completion from the gpt-4.1-nano model. Ensure your API key is set as an environment variable. ```bash curl -X POST https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4.1-nano", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` -------------------------------- ### Multi-Step Workflow Labelling Example Source: https://nexusapilabs.com/docs/api/multi-step-workflows This example demonstrates how to label API calls for a multi-step workflow. The first call expands a prompt, and its request ID is used as the parent for subsequent image generation calls. Use `X-Nexus-Purpose` for a short label and `X-Nexus-Parent-Request-Id` to group related calls. ```bash # 1. Prompt expansion (one chat call) RESP=$(curl -s -X POST https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer nx_..." \ -H "X-Nexus-Purpose: prompt-expansion" \ -d '{"model":"gpt-4o-mini","messages":[...]}) PARENT=$(echo $RESP | jq -r '.x_nexus.request_id') # 2-5. Image generation (4 calls, all linked to the parent) for page in 1 2 3 4; do curl -s -X POST https://nexusapilabs.com/api/v1/images/generations \ -H "Authorization: Bearer nx_..." \ -H "X-Nexus-Purpose: storybook-page-$page" \ -H "X-Nexus-Parent-Request-Id: $PARENT" \ -d "{\"model\":\"flux-2-pro\",\"prompt\":\"...\"}" done ``` -------------------------------- ### Node.js OpenAI SDK Streaming Example Source: https://nexusapilabs.com/docs/streaming This example demonstrates how to use the OpenAI Node.js SDK for streaming chat completions. Set `stream: true` in your request. ```javascript import OpenAI from 'openai'; const openai = new OpenAI({ apiKey: 'nx_your_key', baseURL: 'https://nexusapilabs.com/api/v1', }); async function main() { const stream = await openai.chat.completions.create({ model: 'gpt-4o-mini', messages: [{ role: 'user', content: 'Explain quantum computing' }], stream: true, }); for await (const chunk of stream) { process.stdout.write(chunk.choices[0]?.delta?.content || ''); } } ``` -------------------------------- ### Example API Request for DeepSeek Coder V2 Source: https://nexusapilabs.com/docs/models/deepseek-coder-v2 This snippet demonstrates how to make a POST request to the Nexus API to get a completion from the DeepSeek Coder V2 model. Ensure you have your API key set as an environment variable. ```shell curl -X POST https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek-coder-v2", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` -------------------------------- ### SSE Response Format Example Source: https://nexusapilabs.com/docs/streaming This example shows the structure of a Server-Sent Events (SSE) response for chat completions, including data chunks and the final DONE signal. ```text data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]} data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" world"},"finish_reason":null}]} data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]} data: [DONE] ``` -------------------------------- ### Verifying the Signature (Node.js Example) Source: https://nexusapilabs.com/docs/webhooks Implement signature verification to ensure the integrity and authenticity of incoming webhook requests. This example uses Node.js with Express. ```APIDOC ## Verifying the signature (Node.js Express) Reconstruct the signed payload as `{timestamp}.{raw_body}`, HMAC-SHA256 it with your secret, and compare hex digests using a constant-time function. Reject if the timestamp is older than 5 minutes. ### Endpoint `POST /webhooks/nexus` ### Middleware Use `express.raw({ type: 'application/json' })` to capture the raw request body. ### Logic 1. Retrieve `X-Nexus-Signature` and `X-Nexus-Timestamp` headers. 2. Check for timestamp validity (within 5 minutes). 3. Construct the signed payload: `${timestamp}.${req.body.toString('utf8')}`. 4. Compute the expected signature using HMAC-SHA256 with your `NEXUS_WEBHOOK_SECRET`. 5. Compare the computed signature with the received signature using `crypto.timingSafeEqual`. 6. Respond with `200 OK` if valid, or `400/401` if invalid or out of window. ### Code Example ```javascript import crypto from 'node:crypto' import express from 'express' const app = express() const SECRET = process.env.NEXUS_WEBHOOK_SECRET const REPLAY_WINDOW = 300 // 5 minutes // Capture raw body — required for signature verification app.post('/webhooks/nexus', express.raw({ type: 'application/json' }), (req, res) => { const signature = req.header('X-Nexus-Signature') const timestamp = req.header('X-Nexus-Timestamp') if (!signature || !timestamp) return res.status(400).send('missing signature headers') // Replay protection — reject anything older than 5 minutes if (Math.abs(Date.now() / 1000 - Number(timestamp)) > REPLAY_WINDOW) { return res.status(400).send('timestamp out of replay window') } const signed = `${timestamp}.${req.body.toString('utf8')}` const expected = crypto.createHmac('sha256', SECRET).update(signed).digest('hex') if (!crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature))) { return res.status(401).send('invalid signature') } const event = JSON.parse(req.body.toString('utf8')) // process event ... res.status(200).send('ok') }) ``` ``` -------------------------------- ### Generate Image with SDXL 1.0 Self-Hosted Source: https://nexusapilabs.com/docs/models/sdxl-self-hosted Example of how to generate an image using the SDXL 1.0 self-hosted model via a POST request to the Nexus API. ```bash curl -X POST https://nexusapilabs.com/api/v1/images/generations \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "sdxl-self-hosted", "prompt": "A watercolor painting of a coastal town", "size": "1024x1024" }' ``` -------------------------------- ### Example API Request for Wan 2.1 Source: https://nexusapilabs.com/docs/models/wan-2.1-i2v This snippet shows how to make a POST request to the /api/v1/videos endpoint to generate a video using the 'wan-2.1-i2v' model. Ensure you replace $NEXUS_API_KEY with your actual API key. ```bash curl -X POST https://nexusapilabs.com/api/v1/videos \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "wan-2.1-i2v", "prompt": "A majestic mountain landscape at sunrise", "duration": 3 }' ``` -------------------------------- ### Example API Request for DeepSeek R1 Source: https://nexusapilabs.com/docs/models/deepseek-r1 This snippet shows how to make a POST request to the Nexus API to get a chat completion from the DeepSeek R1 model. Ensure you have your API key set as an environment variable. ```bash curl -X POST https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek-r1", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` -------------------------------- ### Example API Request for eleven_english_sts_v2 Source: https://nexusapilabs.com/docs/models/eleven_english_sts_v2 Demonstrates how to make a POST request to the Nexus API for speech-to-speech conversion using the eleven_english_sts_v2 model. Ensure your API key is set as an environment variable. ```bash curl -X POST https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "eleven_english_sts_v2", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` -------------------------------- ### Example API Request for DeepSeek V3 Source: https://nexusapilabs.com/docs/models/deepseek-v3 This snippet shows how to make a POST request to the Nexus API to get a completion from the DeepSeek V3 model. Ensure your API key is set as an environment variable. ```curl curl -X POST https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek-v3", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` -------------------------------- ### Example LTX-Video API Request Source: https://nexusapilabs.com/docs/models/ltx-video This snippet shows how to make a POST request to the LTX-Video API. Ensure you replace $NEXUS_API_KEY with your actual API key and adjust the JSON payload as needed. ```bash curl -X POST https://nexusapilabs.com/api/v1/videos \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "ltx-video", "prompt": "A majestic mountain landscape at sunrise", "duration": 2 }' ``` -------------------------------- ### Example Sora 2 API Request Source: https://nexusapilabs.com/docs/models/sora-2 Demonstrates how to make a POST request to the Nexus API to generate a video using the Sora 2 model. Ensure you replace $NEXUS_API_KEY with your actual API key. ```bash curl -X POST https://nexusapilabs.com/api/v1/videos \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "sora-2", "prompt": "A majestic mountain landscape at sunrise", "duration": 4, "size": "720x1280" }' ``` -------------------------------- ### Hunyuan Video API Request Example Source: https://nexusapilabs.com/docs/models/hunyuan-video Example of how to make a POST request to the Hunyuan Video API to generate a video. Ensure you replace $NEXUS_API_KEY with your actual API key. ```curl curl -X POST https://nexusapilabs.com/api/v1/videos \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "hunyuan-video", "prompt": "A majestic mountain landscape at sunrise", "duration": 2 }' ``` -------------------------------- ### Example API Request for Character LoRA Training Source: https://nexusapilabs.com/docs/models/character-lora-train Demonstrates how to send a POST request to the Character LoRA Training model API. Ensure you replace $NEXUS_API_KEY with your actual API key. ```bash curl -X POST https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "character-lora-train", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` -------------------------------- ### Generate Image with SD Inpaint Source: https://nexusapilabs.com/docs/models/sd-inpaint Example of how to make an API request to generate an image using the sd-inpaint model. Ensure you have your API key set in the NEXUS_API_KEY environment variable. ```bash curl -X POST https://nexusapilabs.com/api/v1/images/generations \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "sd-inpaint", "prompt": "A watercolor painting of a coastal town", "size": "1024x1024" }' ``` -------------------------------- ### Webhook Payload Example Source: https://nexusapilabs.com/docs/webhooks This is an example of a completed image job payload. Other event types like `video.completed` or `image.failed` will have a similar structure with conditional fields. ```json { "event": "image.completed", "job_id": "job_abc123", "status": "completed", "service_type": "image", "model": "flux-2-pro", "progress": 100, "result_url": "https://cdn.nexus-ai.com/...", "result_expires_at": "2026-05-07T12:00:00Z", "usage": { "price_cents": 4 }, "created_at": "2026-04-30T12:00:00Z", "completed_at": "2026-04-30T12:00:15Z" } ``` -------------------------------- ### Example Nexus AI Response with Routing Information Source: https://nexusapilabs.com/docs/routing This is an example of a response from Nexus AI, including details about the request ID, caching status, latency, and cost. The `x_nexus` field provides valuable metadata for debugging and analysis. ```json { "choices": [...], "usage": { "prompt_tokens": 50, "completion_tokens": 100, "total_tokens": 150 }, "x_nexus": { "request_id": "req_abc123", "cached": false, "latency_ms": 1250, "cost": 0.0015 } } ``` -------------------------------- ### SD 3.5 Image-to-Image Generation Request Source: https://nexusapilabs.com/docs/models/sd35-control-style Example of how to make a POST request to generate an image using the sd35-control-style model. Ensure you replace $NEXUS_API_KEY with your actual API key. ```bash curl -X POST https://nexusapilabs.com/api/v1/images/generations \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "sd35-control-style", "prompt": "A watercolor painting of a coastal town", "size": "1024x1024" }' ``` -------------------------------- ### Example Whisper API Request Source: https://nexusapilabs.com/docs/models/whisper This snippet shows how to make a POST request to the Whisper API for transcription. Ensure you have your API key set as an environment variable. ```bash curl -X POST https://nexusapilabs.com/api/v1/audio/transcriptions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "whisper", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` -------------------------------- ### Example API Request for Clarity Upscaler Source: https://nexusapilabs.com/docs/models/clarity-upscaler This snippet shows how to make a POST request to the Clarity Image Upscaler API to generate an upscaled image. Ensure you replace $NEXUS_API_KEY with your actual API key. ```bash curl -X POST https://nexusapilabs.com/api/v1/images/generations \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "clarity-upscaler", "prompt": "A watercolor painting of a coastal town", "size": "1024x1024" }' ``` -------------------------------- ### Example Image Generation Request Source: https://nexusapilabs.com/docs/models/FLUX-1.1-pro Use this cURL command to generate an image using the FLUX-1.1-pro model. Ensure you replace $NEXUS_API_KEY with your actual API key. ```shell curl -X POST https://nexusapilabs.com/api/v1/images/generations \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "FLUX-1.1-pro", "prompt": "A watercolor painting of a coastal town", "size": "1024x1024" }' ``` -------------------------------- ### Example TTS-1 API Request Source: https://nexusapilabs.com/docs/models/tts-1 Demonstrates how to make a POST request to the NexusAPILabs API to generate speech using the TTS-1 model. Ensure you have your API key set as an environment variable. ```bash curl -X POST https://nexusapilabs.com/api/v1/audio/speech \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "tts-1", "input": "Hello, world.", "voice": "alloy" }' ``` -------------------------------- ### Python OpenAI SDK Streaming Example Source: https://nexusapilabs.com/docs/streaming Use the OpenAI Python SDK to create a streaming chat completion. Ensure you set `stream=True` and iterate over the response chunks. ```python from openai import OpenAI client = OpenAI(api_key="nx_your_key", base_url="https://nexusapilabs.com/api/v1") stream = client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": "Explain quantum computing"}], stream=True, ) for chunk in stream: content = chunk.choices[0].delta.content or "" print(content, end="", flush=True) ``` -------------------------------- ### Example Request for Sync Labs Sync-1 Source: https://nexusapilabs.com/docs/models/sync-labs-sync-1 This snippet shows how to make a POST request to the /api/v1/videos endpoint using the sync-labs-sync-1 model. Ensure you replace $NEXUS_API_KEY with your actual API key. ```curl curl -X POST https://nexusapilabs.com/api/v1/videos \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "sync-labs-sync-1", "prompt": "A majestic mountain landscape at sunrise", "duration": 1 }' ``` -------------------------------- ### Example Sync Labs Sync-2 API Request Source: https://nexusapilabs.com/docs/models/sync-labs-sync-2 Use this cURL command to generate a video with the sync-labs-sync-2 model. Ensure you replace $NEXUS_API_KEY with your actual API key and adjust the duration as needed. ```curl curl -X POST https://nexusapilabs.com/api/v1/videos \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "sync-labs-sync-2", "prompt": "A majestic mountain landscape at sunrise", "duration": 1 }' ``` -------------------------------- ### Example Veo 3 API Request Source: https://nexusapilabs.com/docs/models/veo-3 Use this cURL command to generate a video with the Veo 3 model. Ensure you replace $NEXUS_API_KEY with your actual API key and adjust the JSON payload as needed. ```bash curl -X POST https://nexusapilabs.com/api/v1/videos \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ \ "model": "veo-3", \ "prompt": "A majestic mountain landscape at sunrise", \ "duration": 4 \ }' ``` -------------------------------- ### Example TTS-1-1106 API Request Source: https://nexusapilabs.com/docs/models/tts-1-1106 Demonstrates how to make a POST request to the speech API using the tts-1-1106 model. Ensure you have your API key set as an environment variable. ```bash curl -X POST https://nexusapilabs.com/api/v1/audio/speech \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "tts-1-1106", "input": "Hello, world.", "voice": "alloy" }' ``` -------------------------------- ### SD 3.5 Inpaint API Request Source: https://nexusapilabs.com/docs/models/sd35-edit-inpaint Example of how to make an API request to the SD 3.5 Inpaint model for image generation. Ensure you have your API key set as an environment variable. ```bash curl -X POST https://nexusapilabs.com/api/v1/images/generations \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "sd35-edit-inpaint", "prompt": "A watercolor painting of a coastal town", "size": "1024x1024" }' ``` -------------------------------- ### Example Image Generation Request Source: https://nexusapilabs.com/docs/models/chatgpt-image-latest Use this cURL command to generate an image using the chatgpt-image-latest model. Ensure you replace $NEXUS_API_KEY with your actual API key and adjust the prompt and size as needed. ```shell curl -X POST https://nexusapilabs.com/api/v1/images/generations \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "chatgpt-image-latest", "prompt": "A watercolor painting of a coastal town", "size": "1024x1024" }' ``` -------------------------------- ### Generate Image with FLUX.2-pro Source: https://nexusapilabs.com/docs/models/FLUX.2-pro Example of how to generate an image using the FLUX.2-pro model via a POST request. Ensure your API key is set as an environment variable. ```curl curl -X POST https://nexusapilabs.com/api/v1/images/generations \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "FLUX.2-pro", "prompt": "A watercolor painting of a coastal town", "size": "1024x1024" }' ``` -------------------------------- ### Example API Request for tts-1-hd-1106 Source: https://nexusapilabs.com/docs/models/tts-1-hd-1106 This cURL command demonstrates how to make a POST request to the /api/v1/audio/speech endpoint using the tts-1-hd-1106 model. Ensure you replace $NEXUS_API_KEY with your actual API key. ```bash curl -X POST https://nexusapilabs.com/api/v1/audio/speech \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "tts-1-hd-1106", "input": "Hello, world.", "voice": "alloy" }' ``` -------------------------------- ### Example API Request for Text Embedding 3 Small Source: https://nexusapilabs.com/docs/models/text-embedding-3-small Demonstrates how to call the embeddings API with the text-embedding-3-small model. Ensure your API key is set as an environment variable. ```curl curl -X POST https://nexusapilabs.com/api/v1/embeddings \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "text-embedding-3-small", "input": "The quick brown fox" }' ``` -------------------------------- ### Make a Chat Completion API Call Source: https://nexusapilabs.com/docs Example of how to make a chat completion request using curl. Ensure you replace 'nx_your_key' with your actual API key. ```curl curl https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer nx_your_key" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o-mini", "messages": [{"role": "user", "content": "Hello!"}] }' ``` -------------------------------- ### Example API Request for Gpt 5 Mini Source: https://nexusapilabs.com/docs/models/gpt-5-mini Use this cURL command to send a chat completion request to the Gpt 5 Mini model. Ensure your API key is set as an environment variable. ```shell curl -X POST https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5-mini", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` -------------------------------- ### cURL Streaming Chat Completion Example Source: https://nexusapilabs.com/docs/streaming Initiate a streaming chat completion request using cURL. Set `stream: true` in the JSON payload and accept `text/event-stream`. ```bash curl https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer nx_your_key" \ -H "Content-Type: application/json" \ -d '{ \ "model": "gpt-4o-mini", \ "messages": [{"role": "user", "content": "Explain quantum computing"}], \ "stream": true \ }' ``` -------------------------------- ### Example Request for E5 Mistral 7B Embeddings Source: https://nexusapilabs.com/docs/models/e5-mistral-7b Demonstrates how to make a POST request to the embeddings API endpoint using the e5-mistral-7b model. Ensure you have your NEXUS_API_KEY set as an environment variable. ```bash curl -X POST https://nexusapilabs.com/api/v1/embeddings \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "e5-mistral-7b", "input": "The quick brown fox" }' ``` -------------------------------- ### Example CogVideoX-5B API Request Source: https://nexusapilabs.com/docs/models/cogvideox-5b This cURL command demonstrates how to make a POST request to the Nexus API to generate a video using the cogvideox-5b model. Ensure you replace $NEXUS_API_KEY with your actual API key. ```bash curl -X POST https://nexusapilabs.com/api/v1/videos \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "cogvideox-5b", "prompt": "A majestic mountain landscape at sunrise", "duration": 3 }' ``` -------------------------------- ### Example Image Generation Request Source: https://nexusapilabs.com/docs/models/gpt-image-1.5-2025-12-16 Use this cURL command to generate an image using the GPT Image 1.5 model. Ensure your API key is set and the desired model, prompt, and size are specified. ```bash curl -X POST https://nexusapilabs.com/api/v1/images/generations \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-1.5-2025-12-16", "prompt": "A watercolor painting of a coastal town", "size": "1024x1024" }' ``` -------------------------------- ### Real-ESRGAN Image Upscaling Request Source: https://nexusapilabs.com/docs/models/real-esrgan Example of how to send a POST request to the Real-ESRGAN API endpoint for image upscaling. Ensure you replace $NEXUS_API_KEY with your actual API key. ```bash curl -X POST https://nexusapilabs.com/api/v1/images/generations \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "real-esrgan", "prompt": "A watercolor painting of a coastal town", "size": "1024x1024" }' ``` -------------------------------- ### Example API Request for Whisper Large V3 Source: https://nexusapilabs.com/docs/models/whisper-large-v3 Demonstrates how to send a POST request to the transcription API using the Whisper Large V3 model. Ensure you replace $NEXUS_API_KEY with your actual API key. ```bash curl -X POST https://nexusapilabs.com/api/v1/audio/transcriptions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "whisper-large-v3", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` -------------------------------- ### SDXL Lightning Image Generation Request Source: https://nexusapilabs.com/docs/models/sdxl-lightning Example of how to generate an image using the SDXL Lightning model via a cURL request. Ensure your API key is set as an environment variable. ```bash curl -X POST https://nexusapilabs.com/api/v1/images/generations \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "sdxl-lightning", "prompt": "A watercolor painting of a coastal town", "size": "1024x1024" }' ``` -------------------------------- ### ElevenLabs Music API Request Source: https://nexusapilabs.com/docs/models/eleven_music Example of how to make a POST request to the ElevenLabs Music API endpoint using cURL. Ensure you replace $NEXUS_API_KEY with your actual API key. ```bash curl -X POST https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "eleven_music", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` -------------------------------- ### Example API Request for Scribe v1 Source: https://nexusapilabs.com/docs/models/scribe_v1 This snippet shows how to make a POST request to the ElevenLabs API for transcriptions using the scribe_v1 model. Ensure you have your API key set as an environment variable. ```bash curl -X POST https://nexusapilabs.com/api/v1/audio/transcriptions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "scribe_v1", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` -------------------------------- ### Example API Request for Transcription Source: https://nexusapilabs.com/docs/models/gpt-4o-mini-transcribe This snippet shows how to send a POST request to the transcription API endpoint using cURL. Ensure you replace $NEXUS_API_KEY with your actual API key. ```bash curl -X POST https://nexusapilabs.com/api/v1/audio/transcriptions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o-mini-transcribe", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` -------------------------------- ### Example TTS-1 HD Request Source: https://nexusapilabs.com/docs/models/tts-1-hd Demonstrates how to make a POST request to the Nexus API Labs endpoint for text-to-speech using the TTS-1 HD model. Ensure you have your API key set as an environment variable. ```bash curl -X POST https://nexusapilabs.com/api/v1/audio/speech \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "tts-1-hd", "input": "Hello, world.", "voice": "alloy" }' ``` -------------------------------- ### Example API Request for gpt-image-1-mini Source: https://nexusapilabs.com/docs/models/gpt-image-1-mini This snippet demonstrates how to make a POST request to the Nexus API to generate an image using the gpt-image-1-mini model. Ensure you replace $NEXUS_API_KEY with your actual API key. ```curl curl -X POST https://nexusapilabs.com/api/v1/images/generations \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-1-mini", "prompt": "A watercolor painting of a coastal town", "size": "1024x1024" }' ``` -------------------------------- ### Example Text-to-Speech API Request Source: https://nexusapilabs.com/docs/models/gpt-4o-mini-tts-2025-03-20 Demonstrates how to make a POST request to the Nexus API Labs endpoint for text-to-speech generation using the gpt-4o-mini-tts-2025-03-20 model. Ensure you replace $NEXUS_API_KEY with your actual API key. ```curl curl -X POST https://nexusapilabs.com/api/v1/audio/speech \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o-mini-tts-2025-03-20", "input": "Hello, world.", "voice": "alloy" }' ``` -------------------------------- ### Example Request for ElevenLabs Sound Effects Source: https://nexusapilabs.com/docs/models/eleven_sound_effects This snippet shows how to make a POST request to the ElevenLabs Sound Effects API endpoint. Ensure you replace $NEXUS_API_KEY with your actual API key. ```curl curl -X POST https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "eleven_sound_effects", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` -------------------------------- ### cURL Examples for Nexus AI API Source: https://nexusapilabs.com/docs/sdks Interact with Nexus AI using cURL for chat completions, listing models, and checking billing balance. Ensure your API key is set as an environment variable. ```bash # Chat completion curl https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Hello!"}]}' # List models curl https://nexusapilabs.com/api/v1/models # Check balance curl https://nexusapilabs.com/api/v1/billing/balance \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` -------------------------------- ### ElevenLabs Monolingual v1 API Request Source: https://nexusapilabs.com/docs/models/eleven_monolingual_v1 Example of how to make a POST request to the ElevenLabs Monolingual v1 API to generate speech. Ensure you replace $NEXUS_API_KEY with your actual API key. ```bash curl -X POST https://nexusapilabs.com/api/v1/audio/speech \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "eleven_monolingual_v1", "input": "Hello, world.", "voice": "alloy" }' ``` -------------------------------- ### Chat Completion API Response Example Source: https://nexusapilabs.com/docs/quickstart Example response structure for a chat completion request to the Nexus API. ```json { "id": "chatcmpl-abc123", "object": "chat.completion", "created": 1712345678, "model": "gpt-4o-mini", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "The capital of France is Paris." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 14, "completion_tokens": 8, "total_tokens": 22 }, "x_nexus": { "request_id": "req_abc123def456", "cached": false, "latency_ms": 850, "cost": 0.0001 } } ``` -------------------------------- ### Example Image Generation Request Source: https://nexusapilabs.com/docs/models/gpt-image-1-2025-04-15 Use this cURL command to send a POST request to the Nexus API for image generation. Ensure you replace $NEXUS_API_KEY with your actual API key and adjust the prompt and size as needed. ```curl curl -X POST https://nexusapilabs.com/api/v1/images/generations \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-1-2025-04-15", "prompt": "A watercolor painting of a coastal town", "size": "1024x1024" }' ``` -------------------------------- ### Example API Request for ElevenLabs Multilingual v1 Source: https://nexusapilabs.com/docs/models/eleven_multilingual_v1 This snippet shows how to make a POST request to the ElevenLabs API for text-to-speech conversion using the eleven_multilingual_v1 model. Ensure you replace $NEXUS_API_KEY with your actual API key. ```bash curl -X POST https://nexusapilabs.com/api/v1/audio/speech \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "eleven_multilingual_v1", "input": "Hello, world.", "voice": "alloy" }' ``` -------------------------------- ### Chat Completions Source: https://nexusapilabs.com/docs This endpoint allows you to get chat completions from various AI models through a single OpenAI-compatible interface. You can specify the model, messages, and other parameters to get a response. ```APIDOC ## POST /api/v1/chat/completions ### Description Generates chat completions using the specified AI model. ### Method POST ### Endpoint /api/v1/chat/completions ### Parameters #### Request Body - **model** (string) - Required - The ID of the model to use for chat completions (e.g., "gpt-4o-mini"). - **messages** (array) - Required - A list of message objects, each with a 'role' (user, assistant, system) and 'content'. ### Request Example { "model": "gpt-4o-mini", "messages": [{"role": "user", "content": "Hello!"}] } ### Response #### Success Response (200) - **choices** (array) - A list of completion choices. - **message** (object) - The message content and role. - **role** (string) - The role of the author of the message (e.g., "assistant"). - **content** (string) - The content of the message. #### Response Example { "choices": [ { "message": { "role": "assistant", "content": "Hello! How can I help you today?" } } ] } ``` -------------------------------- ### Example API Request for ElevenLabs Multilingual STS v2 Source: https://nexusapilabs.com/docs/models/eleven_multilingual_sts_v2 Demonstrates how to make a POST request to the ElevenLabs API for speech-to-speech translation using the eleven_multilingual_sts_v2 model. Ensure your API key is set as an environment variable. ```bash curl -X POST https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "eleven_multilingual_sts_v2", "messages": [ { "role": "user", "content": "Hello!" } ] }' ``` -------------------------------- ### Example Nexus AI Response Indicating Cache Hit Source: https://nexusapilabs.com/docs/routing This example demonstrates a response from Nexus AI where the request was served from the semantic cache. Note the `cached` field is true, and the `cost` is 0, indicating a free and fast retrieval. ```json { "choices": [...], "x_nexus": { "request_id": "req_def456", "cached": true, "latency_ms": 8, "cost": 0 } } ``` -------------------------------- ### Opt-in to Caching with max-age Source: https://nexusapilabs.com/docs/api/caching This example shows how to opt-in to response caching using the `X-Nexus-Cache` header with a `max-age` directive. The first call will result in a cache MISS, and subsequent identical calls within the specified TTL will result in a cache HIT. ```bash # Opt in — reuse identical responses for up to 5 minutes curl -X POST https://nexusapilabs.com/api/v1/chat/completions \ -H "Authorization: Bearer nx_..." \ -H "X-Nexus-Cache: max-age=300" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o-mini", "messages": [{"role":"user","content":"Summarise the company handbook"}], "temperature": 0 }' -i # First call — MISS, normal billing HTTP/2 200 X-Nexus-Cache: MISS # Second identical call within 5 min — HIT, $0.00 HTTP/2 200 X-Nexus-Cache: HIT ``` -------------------------------- ### Nexus AI Environment Variables Source: https://nexusapilabs.com/docs/sdks Recommended configuration for Nexus AI API key and base URL using environment variables. ```bash NEXUS_API_KEY=nx_your_api_key_here NEXUS_BASE_URL=https://nexusapilabs.com/api/v1 ``` -------------------------------- ### Example Error Response Structure Source: https://nexusapilabs.com/docs/errors This is a typical error response structure. You can branch on `error.type` for category-level handling and `error.code` for specific cases. ```json { "error": { "type": "invalid_request_error", "code": "unsupported_input_dimension", "message": "Reference image dimension 880x880 is not supported.", "param": "image", "request_id": "req_a1b2c3d4e5f6...", "doc_url": "https://nexusapilabs.com/docs/errors#unsupported_input_dimension", "allowed_sizes": ["720x1280", "1280x720"], "received": { "width": 880, "height": 880 } } } ``` -------------------------------- ### Example Veo 3 Fast API Request Source: https://nexusapilabs.com/docs/models/veo-3-fast Use this cURL command to generate a video with the Veo 3 Fast model. Ensure you replace $NEXUS_API_KEY with your actual API key and adjust the prompt and duration as needed. ```bash curl -X POST https://nexusapilabs.com/api/v1/videos \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "veo-3-fast", "prompt": "A majestic mountain landscape at sunrise", "duration": 4 }' ``` -------------------------------- ### Bearer Token Authentication Header Source: https://nexusapilabs.com/docs/authentication Include your API key in the Authorization header as a Bearer token. API keys start with 'nx_' and are 44 characters long. ```http Authorization: Bearer nx_your_api_key_here ```