CosmicAC Logo

Inference API reference

HTTP routes the inference endpoint serves, with request bodies, responses, and status codes.

The HTTP endpoints served by a deployed inference model. Each route lists its request, response, and errors. In every path, <inference-url> is the base URL of the deployment's inference endpoint.

Endpoints

MethodPathRoute
POST/v1/endpoints/<endpoint-name>/v1/chat/completionsChat completions
POST/v1/endpoints/<endpoint-name>/v1/audio/transcriptionsAudio transcriptions
GET/v1/modelsList models
GET/v1/models/statsModel stats

Authentication

API keys are sent in the Authorization header as a Bearer token. A key must start with the csm_live_ prefix.

Authorization: Bearer csm_live_xxxxxxxxxxxxxxxxxxxxxxxx

The routes use two authentication modes.

ModeBehaviorUsed by
NoneThe route runs no authentication.List models, Model stats
ConditionalCosmicAC enforces authentication only when the endpoint enables require_auth_header. Otherwise it records a valid key for usage tracking, and does not block a missing or invalid key.Chat completions, Audio transcriptions

Chat completions

Returns a chat completion from the model at the named endpoint. Supports non-streaming and streaming (SSE) responses, and multimodal input with image, video, or audio parts.

HTTP request

POST <inference-url>/v1/endpoints/<endpoint-name>/v1/chat/completions

Path parameters

ParameterTypeRequiredDescription
endpoint-namestringYesName of the inference endpoint that serves the model.

Request headers

HeaderTypeRequiredDescription
Content-TypestringYesMust be application/json.
AuthorizationstringNoAPI key as a Bearer token, Bearer csm_live_.... Required only when the endpoint enables require_auth_header.

Request body

{
  "messages": [
    { "role": "system", "content": "You are a helpful assistant." },
    { "role": "user", "content": "Hello!" }
  ],
  "stream": false,
  "temperature": 0.7,
  "max_tokens": 256,
  "top_p": 0.95,
  "frequency_penalty": 0,
  "presence_penalty": 0
}
FieldTypeRequiredDescription
messagesarrayYesConversation history. Must contain at least one message.
messages[].rolestringYesRole of the message author. The route accepts any string.
messages[].contentstring | arrayYesMessage text as a string, or an array of typed parts for multimodal models. CosmicAC rejects any other type. An empty string is valid only when role is assistant.
modelstringNoThe model to call. The serving agent's reported model name overrides this value.
streambooleanNoIf true, the response streams as Server-Sent Events. Defaults to false.
temperaturenumberNoSampling temperature, 0 to 2. Higher values make the output more random, lower values more deterministic.
top_pnumberNoNucleus sampling, 0 to 1. The model considers only the tokens in the top top_p probability mass.
max_tokensnumberNoMaximum number of tokens to generate in the completion. Minimum 1.
frequency_penaltynumberNoPenalty scaled by how often a token has already appeared, -2 to 2. Higher values reduce repetition.
presence_penaltynumberNoPenalty applied to tokens that have already appeared, -2 to 2. Higher values encourage new topics.
nnumberNoNumber of completions to generate. Minimum 1.
stream_optionsobjectNoStreaming options. CosmicAC forwards this object to the model without validating its contents.
stream_options.include_usagebooleanNoCosmicAC sets this field to true on every streaming request, overriding any value you send.
mm_processor_kwargsobjectNoMultimodal processor settings.
mm_processor_kwargs.fpsnumberNoFrames per second to sample from video input.
mm_processor_kwargs.max_framesnumberNoMaximum number of frames to sample from video input.
mm_processor_kwargs.max_pixelsnumberNoMaximum number of pixels per image or frame.
stopstring | string[]NoCosmicAC accepts this field but does not forward it to the model.

Each message uses one form or the other. When messages[].content is an array, each part takes these fields.

FieldTypeRequiredDescription
typestringYesOne of text, image_url, video_url, or audio_url. CosmicAC accepts any other value without further validation.
textstringWhen type is textThe text content of the part.
image_url.urlstringWhen type is image_urlURL of the image.
video_url.urlstringWhen type is video_urlURL of the video.
audio_url.urlstringWhen type is audio_urlURL of the audio.

Response

Non-streaming response.

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1700000000,
  "model": "TinyLlama/TinyLlama-1.1B-Chat-v1.0",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 9,
    "total_tokens": 19
  }
}

The model server produces this body and CosmicAC returns it unchanged.

FieldTypeDescription
idstringIdentifier for the completion.
objectstringAlways chat.completion.
creatednumberUnix timestamp in seconds.
modelstringModel that produced the completion.
choicesarrayGenerated completions. One entry unless n is set higher.
choices[].indexnumberPosition of the choice in the array.
choices[].messageobjectThe generated message.
choices[].message.rolestringRole of the message author, assistant.
choices[].message.contentstringGenerated text.
choices[].finish_reasonstringWhy generation stopped, such as stop or length.
usageobjectToken counts for the request.
usage.prompt_tokensnumberTokens in the prompt.
usage.completion_tokensnumberTokens in the completion.
usage.total_tokensnumberSum of prompt and completion tokens.

Streaming response. When stream is true, the response streams as Server-Sent Events with Content-Type: text/event-stream. Each event is a data: line carrying one completion chunk, and the stream ends with data: [DONE].

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]
FieldTypeDescription
idstringIdentifier for the completion, the same on every chunk.
objectstringAlways chat.completion.chunk.
choicesarrayChunk contents.
choices[].indexnumberPosition of the choice in the array.
choices[].deltaobjectThe increment added by this chunk.
choices[].delta.rolestringPresent on the first chunk only.
choices[].delta.contentstringText fragment added by this chunk.
choices[].finish_reasonstring | nullnull until the final chunk.
usageobjectToken counts, sent on the final chunk because CosmicAC sets include_usage.

Errors

Failed requests return an error object. The structure matches the OpenAI error response.

{
  "error": {
    "message": "No available inference agents for endpoint: <endpoint-name>",
    "type": "invalid_request_error",
    "param": "endpointName",
    "code": "model_not_found"
  }
}
FieldTypeDescription
error.messagestringHuman-readable description of the failure.
error.typestringError category.
error.paramstring | nullThe request field that caused the failure, when CosmicAC can identify it. null otherwise.
error.codestring | nullMachine-readable code. null when the failure carries no specific code.

The type field takes one of these values.

error.typeMeaning
invalid_request_errorThe request was rejected.
server_errorThe endpoint or the model server failed.
errorA streaming response that already started, then broke. Carries message only.

The code field takes one of these values.

error.codeMeaning
invalid_valueA field failed validation. param names the field.
model_not_foundThe endpoint has no replicas available.
nullThe failure carries no specific code.

The route returns these status codes.

StatusMeaning
400The request body failed validation. For example, messages is empty, or temperature is outside 0 to 2.
401An API key is required for this endpoint but was missing or invalid.
502The model server returned an invalid response.
503The endpoint has no available capacity to serve the request.

A request with stream: true returns HTTP 200 as soon as the event stream opens. Failures after that point arrive as a single data: event carrying the error object, followed by data: [DONE]. A streaming request that finds no available capacity reports invalid_request_error with model_not_found. A stream that breaks after it starts sending chunks reports the type error and omits param and code.


Audio transcriptions

Returns a transcription of an audio file, supplied as a file upload or as a URL. The endpoint must serve a speech-to-text model, such as Parakeet. A request to a text-only endpoint fails with 400.

HTTP request

POST <inference-url>/v1/endpoints/<endpoint-name>/v1/audio/transcriptions

Path parameters

ParameterTypeRequiredDescription
endpoint-namestringYesName of the inference endpoint that serves the model.

Request headers

HeaderTypeRequiredDescription
Content-TypestringYesmultipart/form-data for a file upload or an audio_url field, or application/json for an audio_url field.
AuthorizationstringNoAPI key as a Bearer token, Bearer csm_live_.... Required only when the endpoint enables require_auth_header.

Request body

The route accepts audio in one of these forms.

  • multipart/form-data with a file upload.
  • multipart/form-data with an audio_url field.
  • application/json with an audio_url field.
FieldTypeRequiredDescription
filefileNoThe audio file to transcribe, for a multipart upload. Either file or audio_url is required. The maximum size is the endpoint's max_file_size_mb setting.
audio_urlstringNoURL of the audio file to transcribe. Either file or audio_url is required. The format comes from the URL extension, or from the response content type when the URL has no extension.

Example application/json body with a URL.

{
  "audio_url": "https://example.com/audio.mp3"
}

Request size limits

LimitValueDescription
Maximum upload sizemax_file_size_mbSet per endpoint by the Parakeet job that serves it. A larger upload fails with 400.

Response

Success response.

{
  "text": "the transcribed audio text",
  "segments": [
    {
      "start": 0.0,
      "end": 2.5,
      "text": "the transcribed",
      "id": 0,
      "seek": 0,
      "tokens": ["the", "transcribed"],
      "word_count": 2,
      "temperature": 0.0,
      "avg_logprob": null,
      "compression_ratio": null,
      "no_speech_prob": null
    }
  ],
  "words": [
    { "word": "the", "start": 0.0, "end": 0.4 }
  ],
  "language": "en",
  "metadata": {
    "total_segments": 1,
    "total_words": 6,
    "audio_duration": 5.2
  },
  "processing_time": 1.234,
  "transcription_time": 1.234,
  "source": "file"
}
FieldTypeDescription
textstringThe transcribed text.
segmentsarrayTimed segments of the transcription.
segments[].startnumberSegment start time in seconds.
segments[].endnumberSegment end time in seconds.
segments[].textstringText of the segment.
segments[].idnumberPosition of the segment in the array.
segments[].seeknumberPlaceholder for OpenAI compatibility. Always 0.
segments[].tokensarrayWords in the segment. Falls back to the segment text split on whitespace when the model returns no word timings.
segments[].word_countnumberNumber of entries in tokens.
segments[].temperaturenumberPlaceholder for OpenAI compatibility. Always 0.0.
segments[].avg_logprobnullPlaceholder for OpenAI compatibility. Always null.
segments[].compression_rationullPlaceholder for OpenAI compatibility. Always null.
segments[].no_speech_probnullPlaceholder for OpenAI compatibility. Always null.
wordsarrayWord-level timings. Words without timestamps are omitted.
words[].wordstringThe word.
words[].startnumberWord start time in seconds.
words[].endnumberWord end time in seconds.
languagestringAlways en.
metadataobjectCounts describing the transcription.
metadata.total_segmentsnumberNumber of entries in segments.
metadata.total_wordsnumberWord count of the transcription, billed as output.
metadata.audio_durationnumberAudio duration in seconds, billed as input.
processing_timenumberSeconds spent transcribing.
transcription_timenumberSame value as processing_time, kept for backward compatibility.
sourcestringOrigin of the audio, file or url.

Errors

Not every failure on this route returns an error object. Requests that CosmicAC rejects return the error object shown below. Requests the model rejects, such as unsupported or corrupt audio, return the model's own error format instead.

{
  "error": {
    "message": "Endpoint '<endpoint-name>' does not support audio transcriptions. This endpoint's model accepts: text",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}
FieldTypeDescription
error.messagestringHuman-readable description of the failure.
error.typestringError category.
error.paramstring | nullThe request field that caused the failure, when CosmicAC can identify it. null otherwise.
error.codestring | nullMachine-readable code. null when the failure carries no specific code.

The type field takes one of these values.

error.typeMeaning
invalid_request_errorThe request was rejected.
server_errorThe endpoint has no capacity, or the model server failed.

The route returns these status codes.

StatusMeaning
400Content-Type is not multipart/form-data or application/json, the endpoint's model does not support audio input, the upload exceeds max_file_size_mb, audio_url is malformed, or the audio format cannot be determined.
401An API key is required for this endpoint but was missing or invalid.
500The model server failed while transcribing the audio.
503The endpoint has no available capacity to serve the request.

File validation

ValidationStatusDescription
File size400Uploads larger than the endpoint's max_file_size_mb setting.
Audio format400Audio whose format is not one of .wav, .mp3, .flac, .ogg, .m4a, .webm, or .mp4.
URL format400An audio_url value that is not a valid URL.

List models

Lists the models available at the inference endpoint, with availability and modality metadata for each.

HTTP request

GET <inference-url>/v1/models

Response

The data array contains one entry per available model endpoint. The example below shows one ASR model and one vLLM model.

{
  "object": "list",
  "status": "healthy",
  "data": [
    {
      "id": "nvidia/parakeet-tdt-0.6b-v3",
      "object": "model",
      "created": 1783083042,
      "owned_by": "nvidia",
      "endpoint_name": "parakeet-prod",
      "agents_available": 1,
      "job_id": "e2a127bf-5f70-4127-8c42-b93d3978b6cc",
      "status": "healthy",
      "last_health_check": {
        "timestamp": 1783084228663,
        "success": true,
        "response_time_ms": 1142
      },
      "modalities": {
        "input": ["audio"],
        "output": ["text"],
        "pipeline_tag": "automatic-speech-recognition",
        "source": "fallback"
      }
    },
    {
      "id": "Qwen/Qwen2-VL-2B-Instruct",
      "object": "model",
      "created": 1783083126,
      "owned_by": "vllm",
      "root": "Qwen/Qwen2-VL-2B-Instruct",
      "parent": null,
      "max_model_len": 27000,
      "permission": [
        {
          "id": "modelperm-3a3b6d993f074cb59078a9823827ace5",
          "object": "model_permission",
          "created": 1783083126,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "endpoint_name": "qwen-2-prod",
      "agents_available": 2,
      "job_id": "69c06b04-caf5-4776-87a0-2df9ff255b36",
      "status": "healthy",
      "last_health_check": {
        "timestamp": 1783084228663,
        "success": true,
        "response_time_ms": 525
      },
      "modalities": {
        "input": ["text", "image", "video"],
        "output": ["text"],
        "pipeline_tag": "image-text-to-text",
        "source": "fallback"
      }
    }
  ]
}
FieldTypeDescription
objectstringAlways list.
statusstringAggregate health across all endpoints. healthy when every model is healthy, down when every model is down or no models are listed, and degraded otherwise.
dataarrayThe list of available model endpoints.
data[].idstringModel identifier reported by the model server.
data[].objectstringAlways model.
data[].creatednumberUnix timestamp in seconds.
data[].owned_bystringOwner reported by the model server.
data[].endpoint_namestringEndpoint that serves the model.
data[].agents_availablenumberNumber of serving instances available for this model.
data[].job_idstring | nullJob that serves the endpoint. null when no agent reports one.
data[].statusstringEndpoint health, healthy, degraded, or down.
data[].last_health_checkobject | nullMost recent probe result. null before the first probe.
data[].last_health_check.timestampnumberUnix timestamp in milliseconds.
data[].last_health_check.successbooleanWhether the probe succeeded.
data[].last_health_check.response_time_msnumber | nullProbe round trip in milliseconds.
data[].modalitiesobjectInput and output modality metadata.
data[].modalities.inputarrayAccepted input modalities, such as text, image, video, or audio.
data[].modalities.outputarrayProduced output modalities.
data[].modalities.pipeline_tagstringTask tag, such as automatic-speech-recognition.
data[].modalities.sourcestringWhere the modality data came from, huggingface, fallback, or heuristic.

Each data[] entry also carries any other fields the model server reports, such as root, parent, max_model_len, and permission. CosmicAC passes them through unchanged.


Model stats

Returns performance and health statistics for deployed inference endpoints, including per-replica metrics.

HTTP request

GET <inference-url>/v1/models/stats

Query parameters

ParameterTypeRequiredDescription
periodstringNoLookback window for traffic, failures, and latency statistics. One of 1h, 6h, 24h, 7d, or 30d. Defaults to 1h.
overwrite_cachebooleanNoIf true, bypasses the cached response and recomputes the statistics.

Response

The data array contains one entry per endpoint. The example below shows one single-replica endpoint and one two-replica endpoint.

{
  "object": "list",
  "period": "1h",
  "data": [
    {
      "endpoint_name": "parakeet-prod",
      "job_id": "e2a127bf-5f70-4127-8c42-b93d3978b6cc",
      "status": "healthy",
      "success_rate": 100,
      "traffic": 11,
      "failures": 0,
      "avg_response_time_ms": 339.79,
      "timestamp": 1783079163257,
      "last_health_check": {
        "timestamp": 1783079106559,
        "success": true,
        "response_time_ms": 302
      },
      "replicas": [
        {
          "replica_id": "r-01",
          "job_id": "e2a127bf-5f70-4127-8c42-b93d3978b6cc",
          "status": "healthy",
          "success_rate": 100,
          "traffic": 11,
          "failures": 0,
          "avg_response_time_ms": 339.79,
          "timestamp": 1783079163256,
          "last_health_check": {
            "timestamp": 1783079106559,
            "success": true,
            "response_time_ms": 302
          }
        }
      ]
    },
    {
      "endpoint_name": "qwen-2-prod",
      "job_id": "69c06b04-caf5-4776-87a0-2df9ff255b36",
      "status": "healthy",
      "success_rate": 100,
      "traffic": 25,
      "failures": 0,
      "avg_response_time_ms": 233.17,
      "timestamp": 1783079163257,
      "last_health_check": {
        "timestamp": 1783079106559,
        "success": true,
        "response_time_ms": 257
      },
      "replicas": [
        {
          "replica_id": "r-01",
          "job_id": "69c06b04-caf5-4776-87a0-2df9ff255b36",
          "status": "healthy",
          "success_rate": 100,
          "traffic": 12,
          "failures": 0,
          "avg_response_time_ms": 235.94,
          "timestamp": 1783079163256,
          "last_health_check": {
            "timestamp": 1783079106559,
            "success": true,
            "response_time_ms": 257
          }
        },
        {
          "replica_id": "r-02",
          "job_id": "69c06b04-caf5-4776-87a0-2df9ff255b36",
          "status": "healthy",
          "success_rate": 100,
          "traffic": 13,
          "failures": 0,
          "avg_response_time_ms": 230.61,
          "timestamp": 1783079163257,
          "last_health_check": {
            "timestamp": 1783079106559,
            "success": true,
            "response_time_ms": 257
          }
        }
      ]
    }
  ]
}
FieldTypeDescription
objectstringAlways list.
periodstringThe applied lookback window.
dataarrayOne entry per endpoint.
data[].endpoint_namestringName of the endpoint.
data[].job_idstring | nullJob that serves the endpoint. null when no replica reports one.
data[].statusstringEndpoint health, healthy, degraded, or down.
data[].success_ratenumberPercentage of successful requests in the period.
data[].trafficnumberRequest count in the period.
data[].failuresnumberFailed request count in the period.
data[].avg_response_time_msnumberMean response time in milliseconds.
data[].timestampnumberUnix timestamp in milliseconds when CosmicAC built the entry.
data[].last_health_checkobject | nullMost recent probe across the endpoint's replicas. null before the first probe.
data[].last_health_check.timestampnumberUnix timestamp in milliseconds.
data[].last_health_check.successbooleanWhether the probe succeeded.
data[].last_health_check.response_time_msnumber | nullProbe round trip in milliseconds.
data[].replicasarrayPer-replica breakdown.
data[].replicas[].replica_idstringIdentifier of the replica.
data[].replicas[].job_idstring | nullJob that serves the replica.
data[].replicas[].statusstringReplica health, healthy, degraded, or down.
data[].replicas[].success_ratenumberPercentage of successful requests in the period.
data[].replicas[].trafficnumberRequest count in the period.
data[].replicas[].failuresnumberFailed request count in the period.
data[].replicas[].avg_response_time_msnumberMean response time in milliseconds.
data[].replicas[].timestampnumberUnix timestamp in milliseconds when CosmicAC built the entry.
data[].replicas[].last_health_checkobject | nullMost recent probe for this replica.

Errors

Failed requests return an error object. The structure matches the OpenAI error response.

{
  "error": {
    "message": "querystring/period must be equal to one of the allowed values",
    "type": "invalid_request_error",
    "param": "period",
    "code": "invalid_value"
  }
}
FieldTypeDescription
error.messagestringHuman-readable description of the failure.
error.typestringError category.
error.paramstring | nullThe query parameter that caused the failure, when CosmicAC can identify it. null otherwise.
error.codestring | nullMachine-readable code. null when the failure carries no specific code.

The route returns these status codes.

StatusMeaning
400period is not one of the accepted values.

See also

On this page