Skip to main content

Set Up the SDK

1

Create an API Key

npm install -g @anyway-sh/cli
anyway login
anyway developer keys create --name "my-app"
Keep your API key secure. Never commit it to version control.
2

Install the SDK

pip install anyway-sdk
Requires Python 3.10+.
3

Initialize the SDK

from anyway.sdk import Traceloop

Traceloop.init(
    app_name="my-app",
    api_endpoint="https://collector.anyway.sh/",
    headers={"Authorization": "your-api-key"}
)
4

Trace Your LLM Calls

The SDK automatically instruments LLM calls from OpenAI, Anthropic, and other providers. Add workflow and task structure to your traces:
from anyway.sdk.decorators import workflow, task
from openai import OpenAI

client = OpenAI()

@task(name="chat")
def chat(prompt: str) -> str:
    response = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": prompt}]
    )
    return response.choices[0].message.content

@workflow(name="answer_question")
def answer_question(question: str) -> str:
    return chat(question)

result = answer_question("Hello!")
5

View Your Traces

anyway traces status          # check ingestion status
anyway traces list --limit 5  # view recent traces

Next Steps

Python Configuration

Configure the Python SDK.

JavaScript Configuration

Configure the JavaScript SDK.

Distributed Tracing

Learn about tracing and span attributes.

Cost Tracking

Monitor your AI spend.