API Reference
The complete GDK surface. Use the toggles to switch language and GDK version — names and types are shown using each language's own conventions.
New to the GDK? Start with the GDK overview for installation and runnable examples.
Functions
anthropic_default_model
fn anthropic_default_model() -> String
anthropic_provider
fn anthropic_provider(api_key: String, base_url: Option<String>, beta_headers: Vec<String>) -> Result<Provider, GooseError>
| Parameter | Type | Description |
|---|---|---|
api_key | String | — |
base_url | Option<String> | — |
beta_headers | Vec<String> | — |
databricks_default_model
fn databricks_default_model() -> String
databricks_provider
fn databricks_provider(host: String, token: String) -> Result<Provider, GooseError>
| Parameter | Type | Description |
|---|---|---|
host | String | — |
token | String | — |
databricks_v2_default_model
fn databricks_v2_default_model() -> String
databricks_v2_provider
fn databricks_v2_provider(host: String, token: String) -> Result<Provider, GooseError>
| Parameter | Type | Description |
|---|---|---|
host | String | — |
token | String | — |
declarative_provider_from_json
fn declarative_provider_from_json(json: String) -> Result<Provider, GooseError>
| Parameter | Type | Description |
|---|---|---|
json | String | — |
default_compaction_templates
fn default_compaction_templates() -> CompactionTemplates
groq_default_model
fn groq_default_model() -> String
groq_provider
fn groq_provider(api_key: String) -> Result<Provider, GooseError>
| Parameter | Type | Description |
|---|---|---|
api_key | String | — |
install_request_logger
Installs the process-wide provider request logger. A logger can only be installed once for the lifetime of the process.
fn install_request_logger(logger: RequestLogger) -> Result<(), GooseError>
| Parameter | Type | Description |
|---|---|---|
logger | RequestLogger | — |
openai_default_model
fn openai_default_model() -> String
openai_provider
fn openai_provider(api_key: String) -> Result<Provider, GooseError>
| Parameter | Type | Description |
|---|---|---|
api_key | String | — |
Classes
ProviderClass
name
fn Provider.name() -> String
supported_features
fn Provider.supported_features() -> Vec<Feature>
stream
async fn Provider.stream(model: ProviderModelConfig, system: String, messages: Vec<ProviderMessage>, tools: Vec<ProviderTool>) -> Result<ProviderStream, GooseError>
| Parameter | Type | Description |
|---|---|---|
model | ProviderModelConfig | — |
system | String | — |
messages | Vec<ProviderMessage> | — |
tools | Vec<ProviderTool> | — |
complete
async fn Provider.complete(model: ProviderModelConfig, system: String, messages: Vec<ProviderMessage>, tools: Vec<ProviderTool>) -> Result<ProviderCompletion, GooseError>
| Parameter | Type | Description |
|---|---|---|
model | ProviderModelConfig | — |
system | String | — |
messages | Vec<ProviderMessage> | — |
tools | Vec<ProviderTool> | — |
compact
Summarizes a conversation down to a single message so it can continue past this model's context window.
async fn Provider.compact(model_name: String, messages: Vec<CompactionMessage>, templates: Option<CompactionTemplates>) -> Result<CompactionSummary, GooseError>
| Parameter | Type | Description |
|---|---|---|
model_name | String | — |
messages | Vec<CompactionMessage> | — |
templates | Option<CompactionTemplates> | — |
ProviderStreamClass
next_chunk
async fn ProviderStream.next_chunk() -> Result<Option<StreamChunk>, GooseError>
Interfaces
RequestLoggerInterface
Receives provider request logs as JSONL records. `start` returns an identifier that is passed to `write` for every record in that request, allowing callers to keep concurrent request logs separate.
start
fn RequestLogger.start() -> Result<u64, GooseError>
write
fn RequestLogger.write(request_id: u64, record: String) -> Result<(), GooseError>
| Parameter | Type | Description |
|---|---|---|
request_id | u64 | — |
record | String | — |
Data types
ProviderMessageData type
A text message passed to a provider.
| Field | Type | Description |
|---|---|---|
role | MessageRole | — |
content | Vec<MessageContent> | — |
ProviderToolData type
| Field | Type | Default | Description |
|---|---|---|---|
name | String | — | — |
description | String | — | — |
input_schema_json | String | — | — |
annotations_json | Option<String> | None | — |
ProviderModelConfigData type
| Field | Type | Default | Description |
|---|---|---|---|
model_name | String | — | — |
context_limit | Option<i32> | None | — |
temperature | Option<f32> | None | — |
max_tokens | Option<i32> | None | — |
toolshim | bool | false | — |
toolshim_model | Option<String> | None | — |
request_params_json | Option<String> | None | — |
provider_params_json | Option<String> | None | — |
reasoning | Option<bool> | None | — |
timeout_ms | Option<u64> | None | — |
request_headers | Option<HashMap<String, String>> | None | Per-request HTTP headers attached to the outgoing provider call. These override any static headers configured on the provider. |
UsageData type
| Field | Type | Description |
|---|---|---|
input_tokens | Option<i32> | — |
output_tokens | Option<i32> | — |
total_tokens | Option<i32> | — |
cache_read_input_tokens | Option<i32> | — |
cache_creation_input_tokens | Option<i32> | — |
reasoning_tokens | Option<i32> | — |
model | String | — |
provider_metadata_json | Option<String> | — |
GooseStreamErrorData type
| Field | Type | Description |
|---|---|---|
kind | GooseStreamErrorKind | — |
message | String | — |
retry_after_ms | Option<u64> | — |
ProviderCompletionData type
| Field | Type | Description |
|---|---|---|
message_json | String | — |
usage | Option<Usage> | — |
CompactionMessageData type
A text-only message. Compaction reads conversations as text, so this is the whole input shape callers need across the language boundary.
| Field | Type | Description |
|---|---|---|
role | MessageRole | — |
text | String | — |
CompactionTemplatesData type
Overrides for the summarization and summary-rendering prompts.
| Field | Type | Description |
|---|---|---|
compaction | String | — |
summary | String | — |
CompactionSummaryData type
| Field | Type | Description |
|---|---|---|
text | String | — |
input_tokens | Option<i32> | — |
output_tokens | Option<i32> | — |
total_tokens | Option<i32> | — |
Enums
MessageRoleEnum
| Case | Associated data |
|---|---|
User | — |
Assistant | — |
Tool | — |
MessageContentEnum
| Case | Associated data |
|---|---|
Text | text: String |
Image | mime_type: Stringdata: Vec<u8> |
ToolRequest | id: Stringname: Stringarguments_json: String |
ToolResult | id: Stringsuccess: boolcontent_json: String |
Thinking | thinking: Stringsignature: String |
RedactedThinking | data: String |
StreamChunkEnum
| Case | Associated data |
|---|---|
TextChunk | text: String |
ToolChunk | id: Stringname: Stringarguments_json: String |
ThinkingChunk | thinking: Stringsignature: String |
RedactedThinkingChunk | data: String |
EndChunk | usage: Option<Usage> |
ErrorChunk | error: GooseStreamError |
GooseStreamErrorKindEnum
| Case | Associated data |
|---|---|
RateLimited | — |
OutputTokenLimitExceeded | — |
ContextLengthExceeded | — |
Authentication | — |
Timeout | — |
ProviderUnavailable | — |
Generic | — |
FeatureEnum
| Case | Associated data |
|---|---|
Tools | — |
Streaming | — |
Images | — |
JsonSchema | — |
Reasoning | — |
Errors
GooseErrorError
| Variant | Associated data |
|---|---|
RateLimited | retry_after_ms: Option<u64>retry_after_suffix: String |
OutputTokenLimitExceeded | details: String |
ContextLengthExceeded | details: String |
Authentication | details: String |
Timeout | details: String |
ProviderUnavailable | details: String |
Generic | details: String |