Skip to main content

Python SDK for EdgeCrab — a Rust-native autonomous coding agent

Project description

edgecrab-sdk

PyPI Python

Python SDK for EdgeCrab — a Rust-native autonomous coding agent.

Install

pip install edgecrab-sdk

Quick Start

from edgecrab import EdgeCrabClient

# Connect to a running EdgeCrab API server
client = EdgeCrabClient(
    base_url="http://127.0.0.1:8642",
    api_key="your-api-key",  # optional
)

# Simple chat
reply = client.chat("Explain Rust ownership in 3 sentences")
print(reply)

# With system prompt
reply = client.chat(
    "Refactor this function",
    system="You are a senior Rust developer",
    model="anthropic/claude-sonnet-4-20250514",
)

Async

import asyncio
from edgecrab import AsyncEdgeCrabClient

async def main():
    async with AsyncEdgeCrabClient() as client:
        reply = await client.chat("Hello!")
        print(reply)

asyncio.run(main())

Agent API (recommended)

from edgecrab import Agent

agent = Agent(
    model="anthropic/claude-sonnet-4-20250514",
    system_prompt="You are a helpful coding assistant",
)

# Chat with automatic conversation history
reply = agent.chat("Explain Rust ownership")
print(reply)

# Continue the conversation
follow_up = agent.chat("Give me an example")
print(follow_up)

# Full run with result metadata
result = agent.run("Refactor this function")
print(result.response)
print(f"Turns: {result.turns_used}, Tokens: {result.usage.total_tokens}")

Streaming

from edgecrab import EdgeCrabClient, ChatMessage

with EdgeCrabClient() as client:
    messages = [ChatMessage(role="user", content="Write a haiku about Rust")]
    for chunk in client.stream_completion(messages=messages):
        for choice in chunk.choices:
            if choice.delta.content:
                print(choice.delta.content, end="", flush=True)
    print()

CLI

edgecrab chat "What is the meaning of life?"
edgecrab chat --model gpt-4 --system "Be concise" "Explain monads"
edgecrab chat --stream "Tell me a story"
edgecrab models
edgecrab health

Environment Variables

Variable Description
EDGECRAB_BASE_URL API server URL (default: http://127.0.0.1:8642)
EDGECRAB_API_KEY Bearer token for authentication

API Reference

EdgeCrabClient

Method Description
chat(message, *, model, system, temperature, max_tokens) Simple chat — returns string
create_completion(messages, *, model, temperature, max_tokens, tools) Full completion — returns ChatCompletionResponse
stream_completion(messages, *, model, temperature, max_tokens, tools) Streaming — yields StreamChunk
list_models() List available models
health() Health check

AsyncEdgeCrabClient

Same API as EdgeCrabClient, but all methods are async.

Agent / AsyncAgent

Method Description
chat(message) Send message, return reply. Maintains history.
run(message, *, max_turns) Full conversation run — returns AgentResult
add_message(role, content) Inject a message into history
reset() Clear history, start new session
get_messages() Get conversation history
get_turn_count() Number of completed turns
get_usage() Accumulated token usage
list_models() List available models
health() Check server health

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

edgecrab_sdk-0.3.0.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

edgecrab_sdk-0.3.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file edgecrab_sdk-0.3.0.tar.gz.

File metadata

  • Download URL: edgecrab_sdk-0.3.0.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for edgecrab_sdk-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7ce3b6c3f14f7e9fa600a9de0ac4427eb4bb8c26c8a9ccfe79867e239b7d7571
MD5 d910e5690581a9e8c9c195f5f4ff61dc
BLAKE2b-256 20a9937e6e7bb0758869759036ed0a6c3d916b341445ef99e4452581150f24b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for edgecrab_sdk-0.3.0.tar.gz:

Publisher: release-python.yml on raphaelmansuy/edgecrab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file edgecrab_sdk-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: edgecrab_sdk-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for edgecrab_sdk-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 451054efdb59c067154a301cce60c68bdd6af79e16aae839c7983d61aef85b7d
MD5 6c59be64fe6d329fd57a6f33dfd2f2dd
BLAKE2b-256 dcb4c83f2538e2befd875797373d6b0e6f0be61aad5c31924bc4bf9314247cb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for edgecrab_sdk-0.3.0-py3-none-any.whl:

Publisher: release-python.yml on raphaelmansuy/edgecrab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page