SwiftClaw
Introduction to SwiftClawQuick StartInstallationConfiguration

Authentication

Authentication OverviewAPI KeysWebhooks

API Reference

API OverviewREST APISDK Reference

Core Concepts

Understanding AgentsWorkspacesEnvironments

CLI

CLI ReferenceCLI CommandsCLI Configuration
SwiftClaw

SDK Reference

Official SDKs for SwiftClaw

SDK Reference

Official SDKs for interacting with SwiftClaw agents.

Installation

pip install swiftclaw
npm install @swiftclaw/sdk
go get github.com/swiftclaw/swiftclaw-go
gem install swiftclaw

Quick Start

from swiftclaw import SwiftClaw

client = SwiftClaw(api_key="sk_live_abc123...")

response = client.agents.invoke(
    agent="my-agent",
    message="Hello, world!"
)

print(response.message)
import { SwiftClaw } from '@swiftclaw/sdk';

const client = new SwiftClaw({
  apiKey: 'sk_live_abc123...'
});

const response = await client.agents.invoke({
  agent: 'my-agent',
  message: 'Hello, world!'
});

console.log(response.message);
package main

import (
    "github.com/swiftclaw/swiftclaw-go"
)

func main() {
    client := swiftclaw.New("sk_live_abc123...")

    response, err := client.Agents.Invoke(&swiftclaw.InvokeParams{
        Agent:   "my-agent",
        Message: "Hello, world!",
    })

    if err != nil {
        panic(err)
    }

    println(response.Message)
}
require 'swiftclaw'

client = SwiftClaw::Client.new(api_key: 'sk_live_abc123...')

response = client.agents.invoke(
  agent: 'my-agent',
  message: 'Hello, world!'
)

puts response.message

Configuration

Environment Variables

# .env
SWIFTCLAW_API_KEY=sk_live_abc123...
SWIFTCLAW_BASE_URL=https://api.swiftclaw.io

Custom Configuration

client = SwiftClaw(
    api_key="sk_live_abc123...",
    base_url="https://api.swiftclaw.io",
    timeout=30,
    max_retries=3
)
const client = new SwiftClaw({
  apiKey: 'sk_live_abc123...',
  baseURL: 'https://api.swiftclaw.io',
  timeout: 30000,
  maxRetries: 3
});

Agents

Invoke Agent

response = client.agents.invoke(
    agent="my-agent",
    message="What's the weather?",
    context={
        "user_id": "user123",
        "session_id": "session456"
    }
)
const response = await client.agents.invoke({
  agent: 'my-agent',
  message: "What's the weather?",
  context: {
    userId: 'user123',
    sessionId: 'session456'
  }
});

Stream Response

stream = client.agents.invoke_stream(
    agent="my-agent",
    message="Tell me a story"
)

for chunk in stream:
    print(chunk.content, end="")
const stream = await client.agents.invokeStream({
  agent: 'my-agent',
  message: 'Tell me a story'
});

for await (const chunk of stream) {
  process.stdout.write(chunk.content);
}

List Agents

agents = client.agents.list(
    limit=10,
    offset=0
)

for agent in agents:
    print(agent.name)
const agents = await client.agents.list({
  limit: 10,
  offset: 0
});

agents.forEach(agent => {
  console.log(agent.name);
});

Deployments

Create Deployment

deployment = client.deployments.create(
    agent="my-agent",
    environment="production",
    version="v1.2.0"
)
const deployment = await client.deployments.create({
  agent: 'my-agent',
  environment: 'production',
  version: 'v1.2.0'
});

Logs

Get Logs

logs = client.logs.list(
    agent="my-agent",
    level="error",
    limit=50
)

for log in logs:
    print(f"{log.timestamp}: {log.message}")
const logs = await client.logs.list({
  agent: 'my-agent',
  level: 'error',
  limit: 50
});

logs.forEach(log => {
  console.log(`${log.timestamp}: ${log.message}`);
});

Error Handling

from swiftclaw.exceptions import (
    SwiftClawError,
    AuthenticationError,
    RateLimitError
)

try:
    response = client.agents.invoke(
        agent="my-agent",
        message="Hello"
    )
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")
except SwiftClawError as e:
    print(f"Error: {e.message}")
import {
  SwiftClawError,
  AuthenticationError,
  RateLimitError
} from '@swiftclaw/sdk';

try {
  const response = await client.agents.invoke({
    agent: 'my-agent',
    message: 'Hello'
  });
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.log('Invalid API key');
  } else if (error instanceof RateLimitError) {
    console.log(`Rate limited. Retry after ${error.retryAfter}s`);
  } else if (error instanceof SwiftClawError) {
    console.log(`Error: ${error.message}`);
  }
}

Async/Await

import asyncio
from swiftclaw import AsyncSwiftClaw

async def main():
    client = AsyncSwiftClaw(api_key="sk_live_abc123...")

    response = await client.agents.invoke(
        agent="my-agent",
        message="Hello"
    )

    print(response.message)

asyncio.run(main())
// Node.js SDK is async by default
const response = await client.agents.invoke({
  agent: 'my-agent',
  message: 'Hello'
});

Type Safety: All SDKs include TypeScript definitions and type hints.

Next Steps

  • REST API Reference
  • Authentication
  • Examples

How is this guide ?

Last updated on

REST API

Complete REST API reference for SwiftClaw

Understanding Agents

Core concepts of SwiftClaw agents

On this page

SDK Reference
Installation
Quick Start
Configuration
Environment Variables
Custom Configuration
Agents
Invoke Agent
Stream Response
List Agents
Deployments
Create Deployment
Logs
Get Logs
Error Handling
Async/Await
Next Steps