Expand description
Inference Gateway SDK for Rust
This crate provides a Rust client for the Inference Gateway API, allowing interaction with various LLM providers through a unified interface.
Data types in [crate::generated::schemas] are generated from the upstream
openapi.yaml and re-exported at the crate root. Run task generate-types
to regenerate them after a spec bump.
Modules§
Structs§
- Cache
Control - Cache control settings for prompt caching. Currently only
ephemeralcaching is supported. - Chat
Completion Choice ChatCompletionChoice- Chat
Completion Choice Logprobs - Log probability information for the choice.
- Chat
Completion Message Tool Call ChatCompletionMessageToolCall- Chat
Completion Message Tool Call Chunk ChatCompletionMessageToolCallChunk- Chat
Completion Message Tool Call Function - The function that the model called.
- Chat
Completion Named Tool Choice - Specifies a tool the model should use. Use to force the model to call a specific function.
- Chat
Completion Named Tool Choice Function ChatCompletionNamedToolChoiceFunction- Chat
Completion Stream Choice ChatCompletionStreamChoice- Chat
Completion Stream Choice Logprobs - Log probability information for the choice.
- Chat
Completion Stream Options - Options for streaming response. Only set this when you set
stream: true. - Chat
Completion Stream Response Delta - A chat completion delta generated by streamed model responses.
- Chat
Completion Token Logprob ChatCompletionTokenLogprob- Chat
Completion Token Logprob TopLogprobs Item ChatCompletionTokenLogprobTopLogprobsItem- Chat
Completion Tool ChatCompletionTool- Completion
Usage - Usage statistics for the completion request.
- Completion
Usage Completion Tokens Details - Breakdown of tokens used in a completion.
- Completion
Usage Prompt Tokens Details - Breakdown of tokens used in the prompt.
- Config
Config- Context
Window - Context window information for a model
- Create
Chat Completion Request CreateChatCompletionRequest- Create
Chat Completion Response - Represents a chat completion response returned by model, based on the provided input.
- Create
Chat Completion Stream Response - Represents a streamed chunk of a chat completion response returned by the model, based on the provided input.
- Create
Image Edit Request - Request for
InferenceGatewayAPI::create_image_edit. - Create
Image Request - Request body for creating an image via the OpenAI-compatible Images API.
- Create
Image Variation Request - Request for
InferenceGatewayAPI::create_image_variation. - Create
Messages Request - Request body for creating a message via the Anthropic-compatible Messages API.
- Create
Messages Request Thinking - Configuration for extended thinking.
- Create
Response Request - Request body for creating a model response via the Responses API.
- Create
Speech Request - Request body for generating speech audio via the OpenAI-compatible Audio API.
- Create
Speech Request Input - The text to synthesize into audio (4096 characters maximum).
- Create
Speech Request Instructions - Control the voice of your generated audio with additional instructions. Does not work with
tts-1ortts-1-hd. - Create
Speech Request Language - ISO 639-1 code for the language of the generated speech.
Non-standard extension: OpenAI’s speech API has no language field
(the name matches its transcription API). Forwarded to the
provider as-is; the gateway’s built-in local engine
(
local/qwen3-tts) supportszh,en,de,it,pt,es,ja,ko,frandru, and rejects other codes. - Endpoints
Endpoints- Error
Error- Function
Object FunctionObject- Function
Parameters - The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.
Omitting
parametersdefines a function with an empty parameter list. - Image
- Represents the url or the content of an image generated by the Images API.
- Image
Content Part - Image content part
- Image
Url - Image URL configuration
- Images
Response - Represents the result of an image generation request.
- Images
Response Usage - Usage statistics for the image generation request.
- Images
Response Usage Input Tokens Details - A detailed breakdown of the input tokens.
- Inference
Gateway Client - Client for interacting with the Inference Gateway API
- List
Models Response - Response structure for listing models
- List
Tools Response - Response structure for listing MCP tools
- McpTool
- An MCP tool definition
- Message
- Message structure for provider requests
- Messages
Document Block - A document content block in a Messages API request.
- Messages
Document Source - The source of a document content block. Can be a base64-encoded document or a URL.
- Messages
Error - An error response in the Anthropic error format.
- Messages
Error Error - The error details.
- Messages
Image Block - An image content block in a Messages API request.
- Messages
Image Source - The source of an image content block. Can be a base64-encoded image or a URL.
- Messages
Message - A message in a Messages API request.
- Messages
Metadata - Metadata for a Messages API request.
- Messages
Output Config - Output configuration for a Messages API request.
- Messages
Redacted Thinking Block - A redacted thinking content block in a Messages API request or response. Emitted when thinking content is encrypted for safety reasons; must be passed back unchanged in multi-turn conversations.
- Messages
Response - A message response from the Anthropic-compatible Messages API.
- Messages
Stream Event - A server-sent event emitted while streaming a Messages API response.
The Anthropic Messages API emits a sequence of typed events
(
message_start,content_block_start,content_block_delta,content_block_stop,message_delta,message_stop,ping). - Messages
Stream Event Delta - Present in
content_block_deltaandmessage_deltaevents. Contains the incremental update. - Messages
Text Block - A text content block in a Messages API request or response.
- Messages
Thinking Block - A thinking content block in a Messages API request or response.
- Messages
Tool - A tool definition in the Messages API format. Uses the same
function tool shape as the Responses API but with an optional
cache_controlfield for prompt caching. - Messages
Tool Result Block - A tool result content block in a Messages API request.
- Messages
Tool UseBlock - A tool use content block in a Messages API request or response.
- Messages
Usage - Token usage statistics for a Messages API response, including cache metrics.
- Model
- Common model information
- Model
Modalities - The input and output modalities of a model, mirroring the models.dev dataset shape. Vision models accept
imageininput; image-generation models listimageinoutput- whenoutputcarriesimagebut nottext, the model only generates images and cannot chat. - Pricing
- Pricing information for a model
- Provider
Specific Response - Provider-specific response format. Examples:
- Response
- Represents a model response returned by the Responses API.
- Response
Error - An error object returned when the model fails to generate a response.
- Response
Format Json Object - JSON object response format. An older method of generating JSON responses. Using
json_schemais recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so. - Response
Format Json Schema - JSON Schema response format. Used to generate structured JSON responses.
- Response
Format Json Schema Json Schema - Structured Outputs configuration options, including a JSON Schema.
- Response
Format Json Schema Schema - The schema for the response format, described as a JSON Schema object.
- Response
Format Text - Default response format. Used to generate text responses.
- Response
Function Tool Call - A tool call to a function generated by the model.
- Response
Incomplete Details - Details about why the response is incomplete.
- Response
Input Image - An image input to the model.
- Response
Input Item - A single input item. Most commonly an input message with a role and content.
- Response
Input Text - A text input to the model.
- Response
Output Message - An output message from the model.
- Response
Output Refusal - A refusal generated by the model.
- Response
Output Text - A text output from the model.
- Response
Reasoning - Configuration options for reasoning models.
- Response
Reasoning Item - A reasoning item describing the model’s chain of thought.
- Response
Reasoning Summary Part - A summary part of a reasoning item.
- Response
Stream Event - A server-sent event emitted while streaming a response. The Responses API emits a sequence of typed events (for example
response.created,response.output_text.delta, andresponse.completed). This schema models the common event envelope; which fields are populated depends on the eventtype. - Response
Text Config - Configuration options for a text response from the model. Can be plain text or structured JSON data.
- Response
Text Config Format - An object specifying the format that the model must output.
- Response
Tool - A tool the model may call. Only function tools are modeled here. Note the Responses API uses a flattened function tool shape (
name,description, andparametersat the top level) rather than nesting them under afunctionobject as/chat/completionsdoes. - Response
Usage - Token usage details for the response.
- Response
Usage Input Tokens Details - A detailed breakdown of the input tokens.
- Response
Usage Output Tokens Details - A detailed breakdown of the output tokens.
- SSEvents
- Stream of Server-Sent Events (SSE) yielded by
InferenceGatewayAPI::generate_content_stream. - SsEvent
SsEvent- Text
Content Part - Text content part
- Tool
Call Extra Content - Provider-specific opaque data attached to a tool call. The contents are
not interpreted by the gateway, but must be echoed back verbatim on the
next request that references this tool call. Currently used by Google
Gemini extended-thinking models to carry the per-call
thought_signature. Other providers may ignore the field. - Tool
Call Extra Content Google - Google Gemini-specific extra content.
Enums§
- Cache
Control Type - The cache control type. Currently only
ephemeral. - Chat
Completion Tool Choice Option - Controls which (if any) tool is called by the model.
nonemeans the model will not call any tool and instead generates a message.automeans the model can pick between generating a message or calling one or more tools.requiredmeans the model must call one or more tools. Specifying a particular tool via{"type": "function", "function": {"name": "my_function"}}forces the model to call that tool.noneis the default when no tools are present.autois the default if tools are present. - Chat
Completion Tool Choice Option String nonemeans the model will not call any tool and instead generates a message.automeans the model can pick between generating a message or calling one or more tools.requiredmeans the model must call one or more tools.- Chat
Completion Tool Type - The type of the tool. Currently, only
functionis supported. - Content
Part - A content part within a multimodal message
- Context
Window Source - Source of the context window information
- Create
Chat Completion Request Reasoning Effort - Constrains effort on reasoning for reasoning models. Currently supported values are
minimal,low,medium, andhigh. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response. - Create
Chat Completion Request Response Format - An object specifying the format that the model must output. Setting to
{ "type": "json_schema", "json_schema": {...} }enables Structured Outputs which guarantees the model will match your supplied JSON schema. Setting to{ "type": "json_object" }enables the older JSON mode, which ensures the message the model generates is valid JSON. - Create
Chat Completion Request Stop - Up to 4 sequences where the API will stop generating further tokens.
- Create
Image Request Quality - The quality of the image.
autoselects the best quality for the model. The GPT image models supportlow,medium, andhigh;dall-e-3supportsstandardandhd;dall-e-2supports onlystandard. - Create
Image Request Response Format - The format in which the generated images are returned. Must be
one of
urlorb64_json. - Create
Messages Request System - The system prompt. Can be a string or an array of system content blocks (for prompt caching).
- Create
Messages Request Thinking Type - Always
enabled. - Create
Speech Request Response Format - The audio format of the response.
- Finish
Reason - The reason the model stopped generating tokens. This will be
stopif the model hit a natural stop point or a provided stop sequence,lengthif the maximum number of tokens specified in the request was reached,content_filterif content was omitted due to a flag from our content filters,tool_callsif the model called a tool. - Gateway
Error - Custom error types for the Inference Gateway SDK
- Image
Content Part Type - Content type identifier
- Image
Size - The size of the generated images. The GPT image models support
1024x1024,1536x1024,1024x1536, andauto;gpt-image-2also accepts arbitraryWIDTHxHEIGHTvalues such as1536x864.dall-e-2supports256x256,512x512, and1024x1024;dall-e-3supports1024x1024,1792x1024, and1024x1792. - Image
UrlDetail - Image detail level for vision processing
- Message
Content - Message content - either text or multimodal content parts
- Message
Role - Role of the message sender
- Messages
Document Block Type - Content type identifier. Always
document. - Messages
Document Source Type - The source type.
- Messages
Error Type - Always
error. - Messages
Image Block Type - Content type identifier. Always
image. - Messages
Image Source Type - The source type.
- Messages
Message Content - The content of the message. Can be a string or an array of content blocks.
- Messages
Message Role - The role of the message sender.
- Messages
Output Config Effort - Constrains how much effort the model spends on reasoning. Lower effort yields faster responses and fewer reasoning tokens.
- Messages
Redacted Thinking Block Type - Content type identifier. Always
redacted_thinking. - Messages
Request Content Block - A content block within a Messages API request message.
- Messages
Response Content Block - A content block within a Messages API response.
- Messages
Response Role - Always
assistant. - Messages
Response Stop Reason - The reason the model stopped generating.
- Messages
Response Type - Always
message. - Messages
Stream Event Type - The type of the streamed event.
- Messages
Text Block Type - Content type identifier. Always
text. - Messages
Thinking Block Type - Content type identifier. Always
thinking. - Messages
Tool Choice - Controls which (if any) tool is called by the model.
automeans the model can decide,anymeans the model must use a tool, andtoolforces a specific tool. - Messages
Tool Choice Object Type - Always
tool. - Messages
Tool Choice String - The tool choice mode.
- Messages
Tool Result Block Content - The result content. Can be a string or an array of content blocks.
- Messages
Tool Result Block Type - Content type identifier. Always
tool_result. - Messages
Tool UseBlock Type - Content type identifier. Always
tool_use. - Modality
- A single input or output modality
- Pricing
Source - Source of the pricing information
- Provider
Provider- Provider
Auth Type - Authentication type for providers
- Response
Format Json Object Type - The type of response format being defined. Always
json_object. - Response
Format Json Schema Type - The type of response format being defined. Always
json_schema. - Response
Format Text Type - The type of response format being defined. Always
text. - Response
Function Tool Call Status - The status of the function tool call.
- Response
Function Tool Call Type - The type of the output item. Always
function_call. - Response
Input - Text, image, or file inputs to the model. Either a single text prompt or a list of input items representing a (possibly batched) conversation.
- Response
Input Content Part - A content part within an input message.
- Response
Input Image Detail - The detail level of the image to send to the model.
- Response
Input Image Type - The type of the input item. Always
input_image. - Response
Input Message Content - Text or multimodal content for an input message. Either a string or a list of content parts.
- Response
Input Text Type - The type of the input item. Always
input_text. - Response
Output Content - A content part of an output message.
- Response
Output Item - An output item generated by the model: an output message, a function tool call, or a reasoning item.
- Response
Output Message Role - The role of the output message. Always
assistant. - Response
Output Message Status - The status of the message.
- Response
Output Message Type - The type of the output item. Always
message. - Response
Output Refusal Type - The type of the refusal. Always
refusal. - Response
Output Text Type - The type of the output text. Always
output_text. - Response
Reasoning Effort - Constrains the effort on reasoning for reasoning models. Reducing effort can result in faster responses and fewer reasoning tokens.
- Response
Reasoning Item Status - The status of the reasoning item.
- Response
Reasoning Item Type - The type of the output item. Always
reasoning. - Response
Reasoning Summary - A summary of the reasoning performed by the model, useful for debugging and understanding the model’s reasoning process.
- Response
Reasoning Summary Part Type - The type of the summary. Always
summary_text. - Response
Role - The role of the message input.
- Response
Status - The status of the response generation.
- Response
Text Config Format Type - The type of response format being defined.
- Response
Tool Choice - How the model should select which tool (or tools) to use. Either a mode string (
none,auto,required) or an object forcing a specific tool. - Response
Tool Choice Object Type ResponseToolChoiceObjectType- Response
Tool Choice String - The tool-choice mode.
- Response
Tool Type - The type of the tool. Currently only
function. - SsEvent
Event SsEventEvent- Text
Content Part Type - Content type identifier
Traits§
- Inference
GatewayAPI - Core API interface for the Inference Gateway