External Requests API
- Base URL
https://api.samsar.one- Route prefix
/v2/external- Authentication
- Bearer Samsar API key
- Execution
- Provider-style calls; sync or async by route
- Billing
- Endpoint-specific; credit headers report usage
- Content type
application/json
Legacy /external/* aliases may exist on some deployments, but new integrations should use /v2/external/*.
Use this surface through samsar-js to call hosted Samsar as a managed provider for chat, images, video and audio. A standalone installation can choose the Samsar adapter alongside supported native providers; its validated configuration and saved model preferences determine runtime order. See the model matrix and deployment adapter guide.
This is different from /external_users/*. External users track per-customer credits, history, and login state. External requests are one-off provider-style calls authenticated by a Samsar API key.
Validate a Samsar API key
GET /v2/external/api_key/validate
curl "https://api.samsar.one/v2/external/api_key/validate" \
-H "Authorization: Bearer $SAMSAR_API_KEY"
Success response:
{
"valid": true,
"authType": "api_key",
"email": "admin@example.com",
"remainingCredits": 12000
}
Provider capabilities
GET /v2/external/providers/capabilities
Returns the provider, model, and action capability map used by deployment onboarding.
curl "https://api.samsar.one/v2/external/providers/capabilities"
Validate deployment providers
POST /v2/external/providers/validate
Use this from the local deployment wizard to validate optional provider credentials before enabling model settings. The SDK sends credentials only to the local processor or configured Samsar API host; do not persist provider secrets in client code.
curl -X POST "https://api.samsar.one/v2/external/providers/validate" \
-H "Content-Type: application/json" \
-d '{
"samsarApiKey": "sk_live_...",
"openaiApiKey": "sk-...",
"falApiKey": "fal_...",
"runwayApiKey": "rw_..."
}'
Success response:
{
"providers": {
"samsar": {
"ok": true,
"status": "valid",
"remainingCredits": 12000
}
},
"available": {
"providers": ["samsar"],
"models": ["GOOGLE_TTS", "GPTIMAGE2.5", "HAPPYHORSEI2V", "KIMIK3", "LATENT_SYNC", "LYRIA3", "MMAUDIO", "OPENAI_TTS", "QWEN3.8", "RUNWAYML", "VEO3.1I2V", "WAN2.7PRO", "gemini-4-carbon", "gpt-6.2-astra"],
"actions": ["assistant", "audio", "chat", "image", "lip_sync", "moderation", "sound_effect", "video"]
}
}
Chat
External assistant and chat completions
The external assistant endpoints accept OpenAI-compatible chat completion payloads. They are intended for deployed Samsar environments and other integrations that use Samsar as a managed inference provider.
The /assistant/* paths below are naming aliases for the same provider-style chat handler. They are separate from the session-bound POST /v1/assistant/completion API.
Routes
Create a completion with any of these POST routes:
/v2/external/chat/v2/external/chat/completions— preferred for OpenAI-compatible integrations/v2/external/assistant/v2/external/assistant/completions
Read queued request status with any of these GET routes:
/v2/external/chat/status/v2/external/chat/completions/status/v2/external/assistant/status
The same routes are available under /api/v2/external. Legacy deployments may also expose the unversioned /external prefix. There is no /v2/external/assistant/completions/status route; use /v2/external/assistant/status or the canonical /v2/external/chat/status path.
Synchronous completion
Polling is opt-in. Without a polling control, the endpoint waits for inference and returns the raw OpenAI-compatible completion with HTTP 200.
curl -X POST "https://api.samsar.one/v2/external/chat/completions" \
-H "Authorization: Bearer $SAMSAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.2-astra",
"messages": [
{ "role": "user", "content": "Write a launch caption for a travel reel." }
],
"max_tokens": 300
}'
The default server execution timeout is 10 minutes. Omit stream, or set it to false, for the JSON response shown above. Use streaming for incremental text or queued polling for a durable asynchronous request.
See the final token prices for input, output, and cached-input credits per one million tokens. The listed route-specific rates apply to both public chat/assistant aliases and session assistants. Production agent pipeline inference retains its flat stage pricing.
Send Idempotency-Key or reuse client_request_id when retrying the same logical request in JSON, streaming, or queued mode. The SDK request option is { idempotencyKey: 'stable-request-id' }. When both identifiers are supplied, the client request ID takes precedence. Changed payloads under the same key produce a 409 conflict, delivered as an error event if the stream has opened; completed replays reuse the saved response and original debit. A replay's credit receipt describes that original charge, and polling does not create another inference charge.
Requests awaiting billing confirmation or completion after a timeout can remain pending. Continue checking the existing request with the same key. Paid tools may incur separate charges; see Assistant billing and retries.
When available, billing is returned through these headers:
x-credits-chargedx-credits-remaining
Streaming completion
Set stream: true on the same completion route, without polling controls. The response uses Samsar named Server-Sent Events, not OpenAI's data: [DONE] or chat-completion-delta format.
curl -N -X POST "https://api.samsar.one/v2/external/chat/completions" \
-H "Authorization: Bearer $SAMSAR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: travel-caption-001" \
-d '{"model":"gpt-6.2-astra","messages":[{"role":"user","content":"Write a launch caption for a travel reel."}],"stream":true}'
| Event | Meaning |
|---|---|
request | Contains requestId and the effective idempotencyKey. Save the key for reconnection. |
snapshot | Contains accumulated text and available progress metadata. Replace the displayed text; do not append the whole snapshot. |
completed | Contains the final response, creditsCharged, and remainingCredits after settlement. |
error | Contains code and message, with requestId and status when available. Partial text is not a completed, settled response. |
Reconnect by repeating the POST with the same logical payload and request key. A disconnect does not cancel provider work or settlement. Replays reuse the existing request; switching stream off can retrieve its JSON result without another completed-request debit. Errors after the stream opens arrive as events, so HTTP 200 alone does not indicate success. Read the final credit receipt from completed, rather than expecting response headers to change after streaming starts.
Streaming and queued polling are separate modes. Combining stream: true with async, poll, or a polling response_mode is rejected.
Queued completion with polling
Use polling for long-running assistant work such as narrative or theme generation. It avoids holding one HTTP connection open for the entire model call and allows the request to recover after a client disconnect, network reset, or processor restart.
Generate and persist a stable client_request_id before submitting. Retry the same logical submission with the same ID if the initial response is lost.
The default polling-record lifetime is 24 hours. Requests still awaiting completion can remain pending beyond that period. Retrying with a new key creates a new submission; keep the original key for retries.
curl -X POST "https://api.samsar.one/v2/external/assistant/completions" \
-H "Authorization: Bearer $SAMSAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.2-astra",
"messages": [
{ "role": "user", "content": "Create a cinematic theme for this video." }
],
"response_mode": "polling",
"client_request_id": "video-67df0d8e:theme:v1",
"client_session_id": "video-67df0d8e",
"client_request_key": "theme"
}'
async: true, poll: true, or response_mode: "async" | "poll" | "polling" all enable queued mode. Prefer response_mode: "polling" for new integrations.
The canonical fields are:
| Field | Purpose |
|---|---|
client_request_id | Optional idempotency key. Make it unique for one logical request and reuse it only when retrying that request. |
client_session_id | Optional local session correlation value. It is persisted and echoed only when client_request_id is present. |
client_request_key | Optional local stage or operation name, such as theme or narrative. It is persisted and echoed only when client_request_id is present. |
timeout / timeoutMs | Optional server execution timeout in milliseconds. The default is 600000 (10 minutes). |
A queued request returns HTTP 202:
{
"request_id": "67df0d8ebc4f9d0b7f4fd123",
"requestId": "67df0d8ebc4f9d0b7f4fd123",
"status": "PENDING",
"poll_url": "/v2/external/chat/status?request_id=67df0d8ebc4f9d0b7f4fd123",
"client_request_id": "video-67df0d8e:theme:v1",
"client_session_id": "video-67df0d8e",
"client_request_key": "theme",
"created_at": "2026-07-16T13:00:00.000Z",
"updated_at": "2026-07-16T13:00:00.000Z"
}
poll_url is a relative canonical path. Store request_id as soon as it is returned. If the submit response is lost, you can still look up the request by the persisted client_request_id.
Poll by provider request ID:
curl "https://api.samsar.one/v2/external/chat/status?request_id=67df0d8ebc4f9d0b7f4fd123" \
-H "Authorization: Bearer $SAMSAR_API_KEY"
Or recover by client request ID:
curl "https://api.samsar.one/v2/external/chat/status?client_request_id=video-67df0d8e%3Atheme%3Av1" \
-H "Authorization: Bearer $SAMSAR_API_KEY"
Status reads are immediate rather than long-polling. Poll every 1–2 seconds until the request reaches a terminal state:
| Status | Meaning |
|---|---|
PENDING | Persisted and waiting to be claimed. Polling also repairs a request persisted immediately before a processor restart. |
PROCESSING | Claimed by the hosted processor. An expired worker lease can be reclaimed safely. |
COMPLETED | Terminal success. Read the OpenAI-compatible completion from response. |
FAILED | Terminal failure. Read the provider-safe details from error. |
Terminal status payload examplesCompleted and failed queued inference responses
Completed status response:
{
"request_id": "67df0d8ebc4f9d0b7f4fd123",
"status": "COMPLETED",
"response": {
"id": "chatcmpl_123",
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "A precise cinematic theme..."
},
"finish_reason": "stop"
}
]
},
"creditsCharged": 12,
"remainingCredits": 9988
}
Failed status response (HTTP 200):
{
"request_id": "67df0d8ebc4f9d0b7f4fd123",
"status": "FAILED",
"error": {
"message": "External assistant request failed.",
"code": null,
"status": 500
}
}
Idempotent submission replays return the original request and do not replace its payload. Use a new client_request_id only for an intentional new submission; unresolved requests must retain their original key. Fetch status to obtain completion credit headers and body fields, including after a replay.
Common errors:
400missing authentication headers, missing or invalidmessages, streaming combined with polling controls, or an invalid status lookup ID.401invalid or expired credentials.402insufficient credits for a synchronous request.403the supplied credential type is not supported by this provider route.404request not found for the authenticated account.- Async provider failures are represented by HTTP
200withstatus: "FAILED"and the nestederrorobject.
Embeddings
POST /v2/external/embeddings
Create OpenAI-compatible embedding vectors with text-embedding-3-small at 1536 dimensions. Send one string or up to 100 strings; each input may contain up to 12,000 characters. Billing is 100 credits per 1M tokens.
curl -X POST "https://api.samsar.one/v2/external/embeddings" \
-H "Authorization: Bearer $SAMSAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": ["A launch-ready product description", "A concise campaign tagline"],
"model": "text-embedding-3-small",
"dimensions": 1536
}'
Image
/v2/external/image mounts the canonical Image API behind external-provider authentication. The request bodies, status behavior, and pricing are unchanged; add /v2/external before the documented /image/... path.
| Route | Purpose and billing |
|---|---|
POST /v2/external/image/text_to_image | Generate images at the selected model rates, charged on completion. /generate and /generations are compatibility aliases. |
POST /v2/external/image/assign_title | Generate an image title; the response credit receipt reports the final usage-based charge. |
POST /v2/external/image/enhance | Enhance to the selected resolution; the completed image-model call determines the final charge. |
POST /v2/external/image/remove_branding | Remove brand text at the selected image-edit model rates, charged on completion. |
POST /v2/external/image/add_image_set | Extend an image set at the selected model rates, charged on completion. |
GET /v2/external/image/status | Poll an asynchronous hosted image request. |
The mounted surface also includes image history, receipt-template, receipt-query, and rollup-banner routes. Use the Image API as the canonical contract and rate reference for those paths.
Example:
curl -X POST "https://api.samsar.one/v2/external/image/enhance" \
-H "Authorization: Bearer $SAMSAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"image_url": "https://cdn.example.com/photo.png",
"resolution": "1k"
}'
Async image routes return a request_id. Poll:
curl "https://api.samsar.one/v2/external/image/status?request_id=img_enh_123" \
-H "Authorization: Bearer $SAMSAR_API_KEY"
Video
POST /v2/external/video/{video_route}
The external video surface combines the canonical Video API with standalone provider-first routes for remote deployments that bill through a Samsar API key. Add /v2/external before a documented /video/... path to use the mounted canonical surface; the table below highlights the provider-first additions.
| Route | Purpose |
|---|---|
POST /v2/external/video/text_to_video | Create an express text-to-video request. |
POST /v2/external/video/image_to_video | Animate one public image directly; alias of the direct image-to-video handler. |
POST /v2/external/video/direct_text_to_video | Generate a clip directly from a prompt with a supported text-to-video model. |
POST /v2/external/video/direct_image_to_video | Animate one public image directly, without image generation or the full express narrative pipeline. |
POST /v2/external/video/narrative_to_video | Render a completed singular or branched NarrativeRequest without rerunning prompt generation. |
POST /v2/external/video/text_to_interactive_video | Build and render a branching interactive-video workflow from text. |
POST /v2/external/video/lip_sync | Create a lip-sync video-to-video request from public video_url and audio_url inputs. |
POST /v2/external/video/sound_effect | Create a sound-effect video-to-video request from a public video_url input and prompt. |
GET /v2/external/video/status | Poll by request_id or session_id. |
GET /v2/external/video/{request_id}/status | Path-param status polling alias. |
GET /v2/external/video/status_detailed | Poll detailed status plus normalized video preview data. |
GET /v2/external/video/{request_id}/status_detailed | Path-param detailed status polling alias. |
Final AI-video model-call prices
Studio, rerolls and direct hosted model calls settle on completion. The following final customer prices apply to the named native adapter and configuration; per-second units refer to generated output before scene trimming or padding.
| Model | Adapter | Configuration | Unit | Credits |
|---|---|---|---|---|
RUNWAYML | Runway | Gen-4.5 | second | 14.4 |
VEO3.1 / VEO3.1I2V | Google Cloud | 720p / 1080p, video | second | 24 |
VEO3.1 / VEO3.1I2V | Google Cloud | 720p / 1080p, video + audio | second | 48 |
VEO3.1FAST / VEO3.1I2VFAST | Google Cloud | 720p, video | second | 9.6 |
VEO3.1FAST / VEO3.1I2VFAST | Google Cloud | 720p, video + audio | second | 12 |
VEO3.1FAST / VEO3.1I2VFAST | Google Cloud | 1080p, video | second | 12 |
VEO3.1FAST / VEO3.1I2VFAST | Google Cloud | 1080p, video + audio | second | 14.4 |
HAPPYHORSEI2V | Alibaba international | Happy Horse 1.1, 720p | second | 16.8 |
HAPPYHORSEI2V | Alibaba China / global | Happy Horse 1.1, 720p | second | 14.85228 |
HAILUOPRO | MiniMax | Hailuo 02, 768p, 6 seconds | clip | 33.6 |
HAILUOPRO | MiniMax | Hailuo 02, 768p, 10 seconds | clip | 67.2 |
When a hosted direct Fal AI-video route is enabled, these checked-in model rates apply. A rate entry does not enable a model in every deployment:
| Model key | Configuration | Final hosted charge |
|---|---|---|
SDVIDEO | Stable Video | 9 credits / video |
SKYREELSI2V | SkyReels I2V | 36 credits / video |
VIDUI2V | Vidu I2V, 4 seconds | 24 credits / video |
WANI2V5B | Wan 2.2 5B, 81 frames | 18 credits / video |
WANI2V | Wan 2.2 A14B, 16 fps | 48.6 credits / 81 frames; 72.6 credits / 121 frames |
COSMOS3SUPERI2V | Cosmos 3 Super | 6 credits / rounded second |
KLINGTXTTOVIDSTANDARD / KLINGIMGTOVIDSTANDARD / KLINGIMGTOVIDPRO | Kling 1.6 standard; the current image PRO alias uses the standard endpoint | 6.72 credits / second |
KLINGTXTTOVIDPRO | Kling 1.6 pro, text to video | 11.76 credits / second |
KLINGIMGTOVIDPROMASTER / KLINGIMGTOVID2.1MASTER | Kling 2 master / 2.1 master | 33.6 credits / second |
KLINGIMGTOVID2.1STANDARD | Kling 2.1 standard | 6.72 credits / second |
KLINGIMGTOVID2.1PRO | Kling 2.1 pro | 11.76 credits / second |
KLINGIMGTOVID4 / KLINGTXTTOVID4 | Kling 4, 720p; 5–30 seconds in 5-second steps | 18.84 credits / second |
VEO / VEOI2V | Veo 2 | 60 credits / second |
VEO3.1 / VEO3.1I2V / VEO3.1FLIV | Veo 3.1 standard, audio off / on | 24 / 48 credits per second |
VEO3.1FAST / VEO3.1I2VFAST | Veo 3.1 fast, audio off / on | 12 / 18 credits per second |
HAPPYHORSEI2V | Happy Horse 1.1, 720p | 16.8 credits / second |
HAILUOPRO | Hailuo 02 pro | 9.6 credits / second |
PIXVERSEI2V | PixVerse 4.5 normal, 720p, 5 / 8 seconds | 24 / 48 credits per video |
PIXVERSEI2VFAST | PixVerse 4.5 fast, 720p, 5 / 8 seconds | 48 / 96 credits per video |
PIKA2.2I2V | Pika 2.2, 720p, 5 seconds | 24 credits / video |
SEEDANCEI2V | Seedance 1.5 pro, audio off / on | 144 / 288 credits per million video tokens |
SEEDANCE2.0I2V | Seedance 2.0 | 1.68 credits per thousand video tokens |
SEEDANCE2.5I2V | Seedance 2.5 | 2.568 credits per thousand video tokens |
Per-second rates use the submitted configuration; Seedance video-token rates use measured completed output. The worker saves the tariff before submission. Hosted direct Fal paths without verified tariffs stop before a paid call: this includes Haiper 2.0, Magi Distilled, 10-second Pika 2.2, 121-frame Wan 2.2 5B, and PixVerse durations other than five or eight seconds.
Fal-backed hosted lip-sync calls use these final customer rates:
| Model | Final hosted charge |
|---|---|
SYNCLIPSYNC | 16 credits / measured output second |
LATENTSYNC | 24 credits / video through 40 seconds; 0.6 credits / output second above 40 seconds |
KLINGLIPSYNC | 1.68 credits / billable input-video second; 5-second blocks |
CREATIFYLIPSYNC | 2 credits / measured output second |
HUMMINGBIRDLIPSYNC | 15 credits / requested second (historical fallback) |
LatentSync's above-40-second rate applies to its full output duration. Hummingbird retains a historical application rate; its current provider tariff has not been verified. Each completion receipt uses the billing unit shown in the table.
Fal-backed hosted video sound-effect calls use these final rates:
| Model | Final hosted charge | Configuration |
|---|---|---|
MMAUDIOV2 | 0.12 credits / submitted audio second | 8 seconds when duration is omitted |
MIRELOAI | 1.2 credits / submitted second / sample | 1 sample for new calls; older calls may have 2 samples |
Charges use submitted duration and sample count. Mirelo's sample multiplier is an application billing assumption and has not been invoice-verified. GMICloud routes report their own configuration-specific charges in completion receipts. Keep the same request key while billing confirmation is pending.
Full production agent workflows, including text_to_video and narrative rendering, retain their fixed video prices. A standalone deployment waives local debits when calling hosted Samsar; the hosted call receives one charge. Audio-only sound effects use the audio prices.
Video status and delivery
status and status_detailed also accept POST with request_id or session_id in the JSON body.
Hosted SEEDANCE2.5I2V requests use the validated GMICloud model seedance-2-5-260628 for both the text-to-video agent's scene animation and direct external image-to-video handling. Hosted routing does not fall back to Fal, and one logical layer request is dispatched to one adapter only.
On terminal video failure, both status routes return the exact stored provider or model message instead of replacing it with a generic pipeline error. Compact status exposes it through generationError, expressGenerationError, error, and message. Detailed status also retains the failed asset's error under session.layers, such as aiVideoGenerationError, imageSession.generationError, lipSyncVideoGenerationError, or soundEffectVideoGenerationError.
Session listing, translation, joining, subtitle, reroll, clone, outro/footer, and render-control paths from the Video API are also available through this mounted prefix.
For lip_sync and sound_effect, media inputs must be publicly reachable HTTP(S) URLs. Raw bytes, base64/data URLs, local filesystem paths, localhost URLs, and private network URLs are rejected. Docker deployments should publish local media through configured S3-compatible storage, CloudFront, or another signed/public URL strategy before calling these hosted external routes.
Example:
curl -X POST "https://api.samsar.one/v2/external/video/text_to_video" \
-H "Authorization: Bearer $SAMSAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "A cinematic product launch reel",
"image_model": "GPTIMAGE2.5",
"video_model": "RUNWAYML",
"duration": 10,
"aspect_ratio": "9:16",
"inference_model": "gpt-6.2-astra"
},
"webhookUrl": "https://example.com/webhook"
}'
Image-to-video example:
curl -X POST "https://api.samsar.one/v2/external/video/image_to_video" \
-H "Authorization: Bearer $SAMSAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"image_url": "https://cdn.example.com/scene-1.png",
"prompt": "A polished destination reel",
"video_model": "RUNWAYML",
"aspect_ratio": "16:9"
}
}'
Narrative-to-video example:
curl -X POST "https://api.samsar.one/v2/external/video/narrative_to_video" \
-H "Authorization: Bearer $SAMSAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"narrative_request_id": "687b4127b503e2b4acdf9876"
}
}'
The source can be singular or branched. For a branched source, polling returns a normalized branching manifest with one path per leaf, choice-point metadata, path-specific frame/video state, and aggregate progress. The compact status response avoids raw frame data; status_detailed adds path timelines that reference each shared layer and audio asset by ID for client-side preview.
The request reaches top-level COMPLETED only after every leaf video has rendered. The terminal manifest exposes the complete branching.outputs.paths URL mapping, while compatibility fields keep result_url as the default path, return every leaf in ordered result_urls, and retain branch_results. See Render a narrative as video for the full lifecycle, normalized response, and interactive switching flow.
Lip-sync example:
curl -X POST "https://api.samsar.one/v2/external/video/lip_sync" \
-H "Authorization: Bearer $SAMSAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"video_url": "https://cdn.example.com/clip.mp4",
"audio_url": "https://cdn.example.com/dialogue.wav",
"lip_sync_model": "SYNCLIPSYNC",
"duration": 8,
"prompt": "Match the speaker performance to the supplied audio."
}
}'
Sound-effect example:
curl -X POST "https://api.samsar.one/v2/external/video/sound_effect" \
-H "Authorization: Bearer $SAMSAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"video_url": "https://cdn.example.com/clip.mp4",
"prompt": "Soft ocean waves and distant city ambience",
"sound_effect_model": "MIRELOAI",
"duration": 8
}
}'
Poll:
curl "https://api.samsar.one/v2/external/video/status?request_id=66ff..." \
-H "Authorization: Bearer $SAMSAR_API_KEY"
Detailed status:
curl "https://api.samsar.one/v2/external/video/status_detailed?request_id=66ff..." \
-H "Authorization: Bearer $SAMSAR_API_KEY"
For branched video sessions, read branching.summary to display progress and branching.paths to display each leaf render. In detailed status, build maps of session.layers and session.audioLayers by id, then resolve each selected path's timeline[].layer_id and audio_timeline[].audio_layer_id references to preview its current assets. At a branching.tree.choice_points[].switch_at_seconds boundary, the selected option's leaf_path_ids narrows the candidate final videos; selection_trail provides the exact ordered choices for each leaf.
Audio
Hosted audio is asynchronous. Submit one of the canonical routes below, persist the returned request_id, then poll /v2/external/audio/status.
| Route | Model/provider values | Price |
|---|---|---|
POST /v2/external/audio/text_to_speech | OPENAI, ELEVENLABS, GOOGLE, PLAYAI | 1 credit/request |
POST /v2/external/audio/text_to_music | ELEVENLABS_MUSIC, LYRIA3 | 2 credits/request |
POST /v2/external/audio/text_to_sound_effect | SDAUDIO and configured aliases | 1 credit/request |
POST /v2/external/audio/transcript_align | OpenAI whisper-1 | Usage based; 0.9 credits/min by default |
curl -X POST "https://api.samsar.one/v2/external/audio/text_to_music" \
-H "Authorization: Bearer $SAMSAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "Warm cinematic synth backing track, instrumental only",
"model": "ELEVENLABS_MUSIC",
"duration": 30,
"is_instrumental": true
}
}'
Poll:
curl "https://api.samsar.one/v2/external/audio/status?request_id=66ff..." \
-H "Authorization: Bearer $SAMSAR_API_KEY"
samsar-js
import SamsarClient from 'samsar-js';
const samsar = new SamsarClient({ apiKey: process.env.SAMSAR_API_KEY! });
await samsar.validateV2ExternalSamsarApiKey();
const chat = await samsar.createV2ExternalChatCompletion({
model: 'gpt-6.2-astra',
messages: [{ role: 'user', content: 'Write a concise product caption.' }],
});
const video = await samsar.createV2ExternalVideoRequestFromText({
prompt: 'A cinematic product launch reel',
image_model: 'GPTIMAGE2.5',
video_model: 'RUNWAYML',
duration: 10,
});
const status = await samsar.getV2ExternalVideoStatus(video.data.request_id!);
const imageVideo = await samsar.createV2ExternalVideoRequestFromImage({
image_url: 'https://cdn.example.com/scene-1.png',
video_model: 'RUNWAYML',
});
const lipSync = await samsar.createV2ExternalLipSyncVideo({
video_url: 'https://cdn.example.com/clip.mp4',
audio_url: 'https://cdn.example.com/dialogue.wav',
lip_sync_model: 'SYNCLIPSYNC',
});
const soundEffect = await samsar.createV2ExternalSoundEffectVideo({
video_url: 'https://cdn.example.com/clip.mp4',
prompt: 'Soft ocean waves and distant city ambience',
sound_effect_model: 'MIRELOAI',
});
const detailed = await samsar.getV2ExternalVideoStatusDetailed(lipSync.data.request_id!);
await samsar.requestV2ExternalImage('enhance', {
image_url: 'https://cdn.example.com/photo.png',
resolution: '1k',
});
const music = await samsar.createV2ExternalTextToMusicAudio({
prompt: 'Warm cinematic synth backing track, instrumental only',
model: 'ELEVENLABS_MUSIC',
duration: 30,
is_instrumental: true,
});
const audioStatus = await samsar.getV2ExternalAudioStatus(music.data.request_id!);
The shorter aliases also use the v2 external routes:
validateSamsarApiKeygetExternalProviderCapabilitiesvalidateDeploymentProviderscreateExternalChatcreateExternalChatCompletionrequestExternalImagerequestExternalVideocreateExternalVideoRequestFromTextcreateExternalVideoRequestFromImageListcreateExternalVideoRequestFromImagecreateExternalLipSyncVideocreateExternalSoundEffectVideogetExternalImageStatusgetExternalVideoStatusgetExternalVideoStatusDetailedgetExternalVideoDetailedStatusrequestExternalAudiorequestExternalAudioRoutecreateExternalTextToMusicAudiogetExternalAudioStatus
Direct video model calls, lip-sync and sound-effect layers are charged on completion at the final output prices. Reuse Idempotency-Key for submission retries; a changed payload returns 409, and completed replays retain their original charge. Billing confirmation can remain pending after generation. The full production agent workflow keeps its fixed pricing.