Skip to main content
The SDK exposes the serverless inference surface:
  • client.inference.serverless.chat.completions
  • client.inference.serverless.models
  • client.inference.serverless.completions
  • client.inference.serverless.responses
  • client.inference.serverless.tokenize
  • client.inference.serverless.detokenize
  • client.inference.serverless.health
  • client.inference.serverless.version
The public inference surface exposes chat.completions, models, completions, responses, tokenize, detokenize, health, and version. Model naming: pass a serverless model name that is valid for the selected host. If you are coming from the CLI-managed flow, gateway_api_key is the stored inference API key used by the SDK as inference_api_key.

Choosing A Model Name

  • Choose a serverless model name that is valid for the selected host.
  • If you have Control Plane access for the same Tensormesh environment, discover published serverless models with tm billing pricing serverless list.
  • Use the returned pricing[].model value in your request.
  • If you only have inference credentials, or you are targeting a different serverless host override, ask your operator or admin for the exact serverless model string for that host before sending the request.
If you do not already have a valid serverless model name for your target host, discover it with tm billing pricing serverless list for the same Tensormesh environment, or ask your operator or admin for the exact serverless model string first.

Verified Serverless Endpoint Map

  • client.inference.serverless.chat.completions: OpenAI-compatible chat completions
  • client.inference.serverless.models: list models from the verified serverless host
  • client.inference.serverless.completions: text completions
  • client.inference.serverless.responses: responses API
  • client.inference.serverless.tokenize: tokenize text
  • client.inference.serverless.detokenize: convert token ids back to text
  • client.inference.serverless.health: health endpoint
  • client.inference.serverless.version: version endpoint

Serverless Chat Completions

Use a serverless model name here.

Serverless Model Listing

On the default public serverless host, model listing also works without an inference API key.

Serverless Text Completions

Serverless Responses

Tokenize And Detokenize

Health And Version

On the default public serverless host, these routes also work without an inference API key.

Streaming On Serverless

The text-completions and responses endpoints also support raw SSE access:

Tool Calling

Tool-calling caveats on this SDK surface:
  • tool calling is documented on the chat-completions surface only
  • text_deltas() is a text-oriented helper; use with_streaming_response if you need raw stream lines for richer event handling
  • if your current OpenAI or Fireworks app depends on broader tool-stream semantics, verify the exact wire behavior against your target deployment before migrating

Structured Output

The currently documented structured-output mode is JSON mode:
Structured-output caveats on this SDK surface:
  • response_format.type currently supports only json_object and text
  • JSON Schema-style response_format={"type": "json_schema", ...} is not supported on this surface
  • unsupported extra keys inside response_format are rejected explicitly by the SDK instead of being silently dropped
  • use client.inference.serverless.responses when you want the verified serverless responses endpoint instead of chat completions
  • if an upstream runtime leaks leading <think>...</think> blocks into assistant text, the SDK strips them from message.content, stores the extracted text in message.reasoning when possible, and text_deltas() suppresses those leaked blocks in streamed text output

Raw Responses

Use raw responses when you want the unwrapped HTTP payload instead of the parsed SDK model.

Async Streaming Response Access