@incredible/sdk
TypeScript SDK used for the Incredible API. Supports Anthropic client SDK interface. Swap a single import and keep the rest of your code—function calling, streaming, token counting, and cookbook workflows included.Table of contents
- Features
- Installation
- Configuration
- Quick start
- Messages API
- Function calling
- Streaming responses
- Token counting
- Cookbook compatibility
- Integrations API
- Error handling & debugging
- Helpers reference
- Examples
- Development & contributing
Features
- Anthropic-compatible client – constructor options and method signatures match Anthropic’s SDK.
- Tool calling – send
functions
/tools
, receive structured tool-use events, and feed results back automatically. - Streaming – async iterators that emit the same chunks Anthropic’s SSE API provides.
- Helper utilities – cookbook-style helpers to build
function_call
/function_call_result
messages. - Token counting – mirror Anthropic’s
countTokens
endpoint (forward-compatible). - Cookbook ready – every scenario in
Incredible-API-Cookbook-main/
runs unchanged with this SDK.
Installation
Configuration
Option | Env var | Default |
---|---|---|
apiKey | INCREDIBLE_API_KEY | (optional today) |
baseUrl | INCREDIBLE_BASE_URL | https://api.incredible.one |
timeoutMs | — | 60_000 |
maxRetries | — | 2 |
model
, the SDK defaults to small-1
(the only public model at the moment).
Quick start
response
exposes Anthropic-style fields (tool_calls
, stop_reason
, usage
, etc.) and the raw payload (response.raw
).
Messages API
Function calling
Register tools using Anthropic’s schema (parameters
/ input_schema
). The SDK converts them into Incredible’s JSON automatically and normalises the response back into Anthropic-style tool_use
blocks.
Manual control
Automated helper flow
Let the helpers parse tool calls, execute your registry, and build follow-up messages.Beta tool runner
If you already use Anthropic’sbeta.messages.toolRunner
, you can swap in IncredibleClient
and keep the rest.
Streaming responses
Token counting
Note: /v1/messages/count_tokens
is not yet live on the Incredible API. Expect a 404 until it ships.
Cookbook compatibility
Validated against every scenario in Incredible-API-Cookbook-main:- ✅
01-getting-started/
– chat, streaming, integrations. - ✅
02-function-calling/
– multi-tool workflows, JSON extraction, RPG demos, etc.
Integrations API
Error handling & debugging
- The HTTP client throws typed
Error
instances; the Incredible API error payload is attached when available. - Inspect
response.raw
if you want the exact wire-level payload. tool_calls
andtool_results
help trace agentic workflows.- For 5xx responses, log the request body—especially the
function_call_result
block—to cross-check with the cookbook examples.
Helpers reference
@incredible/sdk/helpers
and mirror the names in the Python SDK.
Examples
examples/basic-usage
– chat, token counting, tool chaining, streaming, integrations.examples/integration-demo
– Apollo CRM flow with connect + execute.