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.0rc2

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.0rc2
File Size Uploaded Provenance
spaik_sdk-1.0.0rc2.tar.gz 423.0 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 518.7 kB

Release files / spaik_sdk-1.0.0rc2.tar.gz

Download URL spaik_sdk-1.0.0rc2.tar.gz
Size 423.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c8ac4c7a03bed787f4fc9c641625579794f395aaa9d3aa49eb988e20577b9fef
BLAKE2b-256 checksum
How to use checksums
ece68983aaba5e10211113e8c784e2a8377b5eb337e657a59f966a6a6ea89838
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","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.0rc2-py3-none-any.whl

Download URL spaik_sdk-1.0.0rc2-py3-none-any.whl
Size 95.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
886800aecfaf72ee6a28af4da129e7eb16b3a83e0b7ce50681c43d37c411c558
BLAKE2b-256 checksum
How to use checksums
962d91c86c10a2539ba9c167016a6b851999e6cab783c15698d153869ae62d84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","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}

Security for spaik-sdk 1.0.0rc2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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