Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

spaik-sdk

Python 3.11+ thread management and agent convenience using canonical AG-UI messages/events. Upgrading from 0.x? See the migration guide.

from spaik_sdk import BaseAgent, LLMModel
from spaik_sdk.models.model_registry import ModelRegistry

agent = BaseAgent(system_prompt="Be helpful.", llm_model=ModelRegistry.CLAUDE_SONNET_5_5)
# A model without a preset: llm_model=LLMModel(family="anthropic", name="claude-new-model")
# A plain ID with an explicit provider: llm_model="my-deployment", provider="azure"
print(agent.get_response_text("Hello"))

Every model is an LLMModel: a family, the exact API ID and capability flags (reasoning, reasoning_min_effort, prompt_caching). Reasoning and token settings come from the model's family, whichever provider hosts it, and a string ID that matches a preset builds the preset. Per-model limits, such as a Claude model that cannot disable thinking, live on presets as reasoning_min_effort; set it yourself on an LLMModel without a preset. A string that matches no preset uses provider defaults; opt into reasoning with LLMModel(..., reasoning=True). provider_kwargs override everything except the model ID. temperature is sent only when set.

Spaik providers build every model for the providers they know, including credentials and proxy mode. Other provider names go through LangChain's init_chat_model, and chat_model= accepts a fully configured LangChain model as a last resort. Current aliases for ModelRegistry.from_name are sonnet, opus, haiku, fable, gpt and gemini flash.

Tools and agent methods

Subclass ToolProvider.get_tools() to supply LangChain BaseTool objects or pass tools directly. Application-owned search tools can use any service; the bundled Tavily helper is removed. persist_tool_block_history=False keeps a tool marker in model replay while retaining the full UI transcript. render_tool_block_for_history(ToolCallHistory) customizes replay; its argument is now a tool-history record rather than a message block.

  • get_response_text() / get_response_text_async() return final text.
  • get_response() / get_response_async() return an AG-UI AssistantMessage.
  • get_event_stream() / get_response_stream() yield AG-UI events.
  • get_structured_response() / get_structured_response_async() return the supplied Pydantic schema and collect raw usage/costs. They use the model's minimum reasoning by default; raise it per call with reasoning_effort="high" or for every call with LLMConfig(structured_reasoning_effort=...).
  • spawn() / run_isolated() isolate nested agent callback contexts.
  • get_langchain_model() and get_react_agent() expose configured LangChain/LangGraph integrations.
  • run_cli() supplies a minimal interactive console without additional CLI dependencies.
  • get_cost() reads recorded charges; it never calls billing APIs.

thread_container.messages contains official AG-UI messages. message_text(message) extracts text. A versioned persistence envelope holds owners, timestamps, attachments, invocation usage/costs and private provider replay data. Signed reasoning and provider-required response data stay separate from display messages.

Server, storage, and optional dependencies

ApiBuilder.local(agent=...) supplies thread CRUD, /threads/{id}/runs SSE, cancellation and file routes. ApiBuilder.stateful(repository, authorizer, agent=...) injects persistence/authorization; agent_factory(thread) constructs application-specific agents. Empty threads have owners. The built-in runner coordinates a single process per repository; use an application integration for distributed workers. It executes backend tools; client tool execution and interrupt resume are outside its current convenience contract.

Install extras as needed: [server], [openai], [anthropic], [google], [azure], [ollama], [deepseek], [mistral], [cohere], [xai], [audio], [mcp], [dev]. Audio helpers use HTTP directly. Core does not import optional model integrations eagerly.

Local persistence uses JSON at data-v1/threads. Application repositories read stored threads with spaik_sdk.thread.migration.load_thread_data, which also converts legacy 0.x JSON in memory. Legacy local pickle stores are exported in the old SDK environment and imported with python -m spaik_sdk.thread.migration export.json new-data-dir. See the migration guide for both.

Provider-reported costs

CostProvider.resolve(CostContext) returns a reported charge or None. OpenRouter reads response usage and performs at most one cached generation lookup when needed. Charges have currency; aggregate CostSummary.totals preserves currencies, and complete is false when charges are missing. Unknown costs never become zero. Account-level billing reports and token-price estimates are not used. Token usage remains available independently.

Development

uv sync --all-extras --dev --locked
make test-unit
make test-integration
make lint
make typecheck

Unit tests are deterministic. Integration tests cover persistence, usage and optional MCP; live provider smoke checks are a separate release gate. The repository's frontend tests consume Python-produced AG-UI SSE and exercise both Spaik and an independent backend.

Metadata

Release files for spaik-sdk 1.0.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spaik-sdk 1.0.0rc1
File Size Uploaded
spaik_sdk-1.0.0rc1.tar.gz 313.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spaik-sdk 1.0.0rc1
File Interpreter ABI Platform
spaik_sdk-1.0.0rc1-py3-none-any.whl Python 3 none any Details

Total release size: 408.7 kB

Release files / spaik_sdk-1.0.0rc1.tar.gz

Download URL spaik_sdk-1.0.0rc1.tar.gz
Size 313.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4f0af2ccb08719a57d3215ed90d0c4af1e5c09be164292cda0289f49aee0c649
BLAKE2b-256 checksum
How to use checksums
61904b557011cbcb7d7e67be262bf4c27f502367404664909a280bcc5b0bcb68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / spaik_sdk-1.0.0rc1-py3-none-any.whl

Download URL spaik_sdk-1.0.0rc1-py3-none-any.whl
Size 95.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e12d3885b9dc90c934666b5778171ce564f001707539010efd4b30231d06d07
BLAKE2b-256 checksum
How to use checksums
1101e2f8eb1747c1e2fe535e4beaed5dc9f55e812e284df5248dd75a850bb3b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

1.0.0rc1 This release

2 release files

0.11.2

2 release files

0.11.0

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.9

2 release files

0.6.8

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page