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§
- 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.
- Config
Config- 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.
- 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
Content Part - Image content part
- Image
Url - Image URL configuration
- 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
- Model
- Common model information
- Provider
Specific Response - Provider-specific response format. Examples:
- 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.
- 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§
- 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
- 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.
- 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
UrlDetail - Image detail level for vision processing
- Message
Content - Message content - either text or multimodal content parts
- Message
Role - Role of the message sender
- 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. - SsEvent
Event SsEventEvent- Text
Content Part Type - Content type identifier
Traits§
- Inference
GatewayAPI - Core API interface for the Inference Gateway