Skip to main content
Register your existing Python functions so agents can call them. Raysurfer wraps your functions with @rs.tool, auto-infers the schema from the signature and docstring, and routes tool calls back to your app during sandbox execution.

Setup

Install the SDK and set RAYSURFER_API_KEY in your environment.
uv add raysurfer

Register Tools

@rs.tool can wrap any Python function. The function signature is converted to schema fields, and the function docstring is used as the tool description in the tool payload.
from raysurfer import AsyncRaySurfer

rs = AsyncRaySurfer(api_key="your_api_key")

@rs.tool
def add(a: int, b: int) -> int:
    """Add two numbers."""
    return a + b

Execute Modes

Use exactly one mode per execute() call:

Primary Mode: Pass user_code

result = await rs.execute(
    "Compute 5 + 3",
    user_code="print(add(5, 3))",
)

Optional Mode: Sandbox Codegen

In this mode, code is generated inside the Daytona sandbox from your prompt.
result = await rs.execute(
    "Compute 5 + 3",
    codegen_api_key="YOUR_ANTHROPIC_API_KEY",
    codegen_prompt="Write Python code that calls add(a, b) for 5 and 3, then prints the result.",
    codegen_model="claude-opus-4-6",
)

Full SDK Reference

See Python SDK for full method signatures and response fields.