Skip to main content

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

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.1
File Size Uploaded Provenance Actions
spaik_sdk-1.0.1.tar.gz 420.6 kB Without provenance Details for spaik_sdk-1.0.1.tar.gz

Built distribution (wheel)

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

Total release size: 516.2 kB

Release files / spaik_sdk-1.0.1.tar.gz

Download URL spaik_sdk-1.0.1.tar.gz
Size 420.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6d52b96d3be41789f1a455518f056b618918262c02c64f25393046b620d66d66
BLAKE2b-256 checksum
How to use checksums
44f5be35669591f1166a6608726ab66fb9362db31ff6ab13bff2b73f77d796b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","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.1-py3-none-any.whl

Download URL spaik_sdk-1.0.1-py3-none-any.whl
Size 95.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
293c36c37255f662877ad2de10c06028e6f34321c1c462ca83e6c2541d2021cc
BLAKE2b-256 checksum
How to use checksums
624ff18a9f8c1ce87492387c4e496920c9569fc1676025def3935dc74f4e505b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","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.1

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