Skip to main content

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.

Generated from crates/goose-sdk/src/bindings.rs at goose-sdk 0.1.0-alpha.13.

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>
ParameterTypeDescription
api_key​String—
base_url​Option<String>—
beta_headers​Vec<String>—

Raises GooseError

databricks_default_model​

fn databricks_default_model() -> String

databricks_provider​

fn databricks_provider(host: String, token: String) -> Result<Provider, GooseError>
ParameterTypeDescription
host​String—
token​String—

Raises GooseError

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>
ParameterTypeDefaultDescription
host​String——
token​String——
gateway_path​Option<String>None—

Raises GooseError

declarative_provider_from_json​

fn declarative_provider_from_json(json: String) -> Result<Provider, GooseError>
ParameterTypeDescription
json​String—

Raises GooseError

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>
ParameterTypeDescription
api_key​String—

Raises GooseError

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>
ParameterTypeDescription
logger​RequestLogger—

Raises GooseError

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>
ParameterTypeDefaultDescription
api_key​String——
base_url​Option<String>None—

Raises GooseError

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>
ParameterTypeDescription
api_key​String—

Raises GooseError

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>
ParameterTypeDescription
api_key​String—
base_url​Option<String>—

Raises GooseError

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>
ParameterTypeDescription
api_key​String—
base_url​Option<String>—

Raises GooseError

Classes​

DecisionProviderClass​

create_decision​

async fn DecisionProvider.create_decision(request: DecisionRequest) -> Result<DecisionResponse, GooseError>
ParameterTypeDescription
request​DecisionRequest—

Raises GooseError

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>
ParameterTypeDescription
model​ProviderModelConfig—

Raises GooseError

list_models​

async fn Provider.list_models() -> Result<Vec<ProviderModelInfo>, GooseError>

Raises GooseError

stream​

async fn Provider.stream(model: ProviderModelConfig, system: String, messages: Vec<ProviderMessage>, tools: Vec<ProviderTool>) -> Result<ProviderStream, GooseError>
ParameterTypeDescription
model​ProviderModelConfig—
system​String—
messages​Vec<ProviderMessage>—
tools​Vec<ProviderTool>—

Raises GooseError

complete​

async fn Provider.complete(model: ProviderModelConfig, system: String, messages: Vec<ProviderMessage>, tools: Vec<ProviderTool>) -> Result<ProviderCompletion, GooseError>
ParameterTypeDescription
model​ProviderModelConfig—
system​String—
messages​Vec<ProviderMessage>—
tools​Vec<ProviderTool>—

Raises GooseError

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>
ParameterTypeDescription
model_name​String—
messages​Vec<CompactionMessage>—
templates​Option<CompactionTemplates>—

Raises GooseError

ProviderStreamClass​

next_chunk​

async fn ProviderStream.next_chunk() -> Result<Option<StreamChunk>, GooseError>

Raises 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>

Raises GooseError

write​

fn RequestLogger.write(request_id: u64, record: String) -> Result<(), GooseError>
ParameterTypeDescription
request_id​u64—
record​String—

Raises GooseError

Data types​

ProviderMessageData type​

A text message passed to a provider.

FieldTypeDescription
role​MessageRole—
content​Vec<MessageContent>—

ProviderToolData type​

FieldTypeDefaultDescription
name​String——
description​String——
input_schema_json​String——
annotations_json​Option<String>None—

ProviderModelConfigData type​

FieldTypeDefaultDescription
model_name​String——
context_limit​Option<i32>None—
temperature​Option<f32>None—
max_tokens​Option<i32>None—
toolshim​boolfalse—
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>>NonePer-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.

FieldTypeDescription
name​String—
context_limit​Option<u64>—
supports_reasoning​bool—

UsageData type​

FieldTypeDescription
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​

FieldTypeDescription
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​

FieldTypeDescription
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​

FieldTypeDescription
true_description​String—
false_description​String—

DecisionRequestData type​

FieldTypeDescription
model​String—
state_json​String—
questions​HashMap<String, DecisionQuestion>—

DecisionResponseData type​

FieldTypeDescription
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.

FieldTypeDescription
role​MessageRole—
text​String—

CompactionTemplatesData type​

Overrides for the summarization and summary-rendering prompts.

FieldTypeDescription
compaction​String—
summary​String—

CompactionSummaryData type​

FieldTypeDescription
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​

CaseAssociated data
User​—
Assistant​—
Tool​—

MessageContentEnum​

CaseAssociated data
Text​
text: String
Image​
mime_type: String
data: Vec<u8>
Document​
mime_type: String
data: Vec<u8>
name: Option<String>
ToolRequest​
id: String
name: String
arguments_json: String
provider_metadata_json: Option<String>
tool_error_json: Option<String>
ToolResult​
id: String
success: bool
content_json: String
Thinking​
thinking: String
signature: String
RedactedThinking​
data: String

StreamChunkEnum​

CaseAssociated data
TextChunk​
text: String
ToolChunk​
id: String
name: String
arguments_json: String
index: Option<i32>
provider_metadata_json: Option<String>
ThinkingChunk​
thinking: String
signature: String
RedactedThinkingChunk​
data: String
EndChunk​
usage: Option<Usage>
ErrorChunk​
error: GooseStreamError

GooseStreamErrorKindEnum​

CaseAssociated data
RateLimited​—
OutputTokenLimitExceeded​—
ContextLengthExceeded​—
Authentication​—
Timeout​—
ProviderUnavailable​—
Generic​—

FeatureEnum​

CaseAssociated data
Tools​—
Streaming​—
Images​—
Documents​—
JsonSchema​—
Reasoning​—

DecisionQuestionEnum​

CaseAssociated data
Noul​
instructions: String
criteria: Option<NoulCriteria>
Choice​
instructions: String
criteria: HashMap<String, String>
Score​
instructions: String
criteria: Vec<String>

DecisionAnswerEnum​

CaseAssociated data
Noul​
noul: f64
Choice​
choice: String
confidence: f64
probabilities: HashMap<String, f64>
Score​
score: f64
confidence: f64
legend_json: HashMap<String, String>
probabilities: HashMap<String, f64>

Errors​

GooseErrorError​

VariantAssociated 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