Python and Kotlin API Reference
The generated reference below covers the goose-sdk UniFFI API used by Python
and Kotlin, with Rust signatures also available for that bindings layer. It is
not the full native Rust GDK API.
This reference is also available as generated Markdown for Python and Kotlin, without JavaScript.
For native Rust, use the crate documentation.
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, gateway_path: Option<String> = None) -> Result<Provider, GooseError>
| Parameter | Type | Default | Description |
|---|---|---|---|
host | String | — | — |
token | String | — | — |
gateway_path | Option<String> | None | — |
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
Create an OpenAI provider with an optional custom base URL. Pass `None` for the default `https://api.openai.com`, or a custom host (e.g. DeepSeek, Kimi) to enable reasoning-context preservation.
fn openai_provider(api_key: String, base_url: Option<String> = None) -> Result<Provider, GooseError>
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | String | — | — |
base_url | Option<String> | None | — |
openai_provider_simple
Simple one-argument wrapper for Rust callers who do not need a custom base URL. This preserves backward compatibility: existing code calling `openai_provider(api_key)` can continue to compile after the `base_url` parameter was added.
fn openai_provider_simple(api_key: String) -> Result<Provider, GooseError>
| Parameter | Type | Description |
|---|---|---|
api_key | String | — |
openrouter_decision_default_model
fn openrouter_decision_default_model() -> String
openrouter_decision_provider
fn openrouter_decision_provider(api_key: String, base_url: Option<String>) -> Result<DecisionProvider, GooseError>
| Parameter | Type | Description |
|---|---|---|
api_key | String | — |
base_url | Option<String> | — |
typesafe_decision_default_model
fn typesafe_decision_default_model() -> String
typesafe_decision_provider
fn typesafe_decision_provider(api_key: String, base_url: Option<String>) -> Result<DecisionProvider, GooseError>
| Parameter | Type | Description |
|---|---|---|
api_key | String | — |
base_url | Option<String> | — |
Classes
DecisionProviderClass
ProviderClass
name
fn Provider.name() -> String
supported_features
fn Provider.supported_features() -> Vec<Feature>
context_limit
async fn Provider.context_limit(model: ProviderModelConfig) -> Result<u64, GooseError>
| Parameter | Type | Description |
|---|---|---|
model | ProviderModelConfig | — |
list_models
async fn Provider.list_models() -> Result<Vec<ProviderModelInfo>, GooseError>
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>
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. |
ProviderModelInfoData type
A model advertised by the provider. Providers without model discovery return an empty list rather than an error.
| Field | Type | Description |
|---|---|---|
name | String | — |
context_limit | Option<u64> | — |
supports_reasoning | bool | — |
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 | — |
request_id | Option<String> | The model vendor's own id for this call: Anthropic sends `request-id`, OpenAI `x-request-id`. |
provider_metadata_json | Option<String> | — |
additional_data_json | Option<String> | Provider-specific response fields as a JSON object, present only when the provider reported fields with no canonical `Usage` equivalent. |
GooseStreamErrorData type
| Field | Type | Description |
|---|---|---|
kind | GooseStreamErrorKind | — |
message | String | — |
retry_after_ms | Option<u64> | — |
request_id | Option<String> | Recovered from the message text, the only channel `ProviderError` has for it. |
ProviderCompletionData type
| Field | Type | Description |
|---|---|---|
message_json | String | — |
content | Vec<MessageContent> | The assistant turn as binding types, ready to append to history and replay on the next request without reparsing `message_json`. |
usage | Option<Usage> | — |
NoulCriteriaData type
| Field | Type | Description |
|---|---|---|
true_description | String | — |
false_description | String | — |
DecisionRequestData type
| Field | Type | Description |
|---|---|---|
model | String | — |
state_json | String | — |
questions | HashMap<String, DecisionQuestion> | — |
DecisionResponseData type
| Field | Type | Description |
|---|---|---|
model | String | — |
answers | HashMap<String, DecisionAnswer> | — |
input_tokens | Option<u64> | — |
output_tokens | Option<u64> | — |
cost | Option<f64> | — |
id | Option<String> | — |
provider | Option<String> | — |
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> | — |
cache_read_input_tokens | Option<i32> | — |
cache_creation_input_tokens | Option<i32> | — |
Enums
MessageRoleEnum
| Case | Associated data |
|---|---|
User | — |
Assistant | — |
Tool | — |
MessageContentEnum
| Case | Associated data |
|---|---|
Text | text: String |
Image | mime_type: Stringdata: Vec<u8> |
Document | mime_type: Stringdata: Vec<u8>name: Option<String> |
ToolRequest | id: Stringname: Stringarguments_json: Stringprovider_metadata_json: Option<String>tool_error_json: Option<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: Stringindex: Option<i32>provider_metadata_json: Option<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 | — |
Documents | — |
JsonSchema | — |
Reasoning | — |
DecisionQuestionEnum
| Case | Associated data |
|---|---|
Noul | instructions: Stringcriteria: Option<NoulCriteria> |
Choice | instructions: Stringcriteria: HashMap<String, String> |
Score | instructions: Stringcriteria: Vec<String> |
DecisionAnswerEnum
| Case | Associated data |
|---|---|
Noul | noul: f64 |
Choice | choice: Stringconfidence: f64probabilities: HashMap<String, f64> |
Score | score: f64confidence: f64legend_json: HashMap<String, String>probabilities: HashMap<String, f64> |
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 |