Documentation Index
Fetch the complete documentation index at: https://docs.anyway.sh/llms.txt
Use this file to discover all available pages before exploring further.
Set Up the SDK
Create an API Key
npm install -g @anyway-sh/cli
anyway login
anyway developer keys create --name "my-app"
Sign up at app.anyway.sh, then go to Developer > API Keys and create a new SDK API key. Keep your API key secure. Never commit it to version control.
Install the SDK
npm install @anyway-sh/node-server-sdk
Requires Node.js 18+.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"}
)
import { initialize } from "@anyway-sh/node-server-sdk";
initialize({
appName: "my-app",
baseUrl: "https://collector.anyway.sh/",
headers: { Authorization: "your-api-key" },
disableBatch: true,
});
For ESM or Next.js projects, pass provider modules explicitly via instrumentModules. See JS Configuration. 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!")
import { withWorkflow, withTask } from "@anyway-sh/node-server-sdk";
import OpenAI from "openai";
const client = new OpenAI();
async function chat(prompt: string) {
return withTask({ name: "chat" }, async () => {
const response = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: prompt }],
});
return response.choices[0].message.content;
});
}
async function answerQuestion(question: string) {
return withWorkflow({ name: "answer_question" }, async () => {
return chat(question);
});
}
const result = await answerQuestion("Hello!");
View Your Traces
anyway traces status # check ingestion status
anyway traces list --limit 5 # view recent traces
Open Agent Traces to see your workflow and task spans with execution hierarchy, duration, token usage, and cost estimates.
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.