Skip to main content

SDK Getting Started

Build your first FAOS integration in 5 minutes. This tutorial walks through installation, authentication, and invoking your first agent.

Duration: 5 minutes | Difficulty: Beginner

Prerequisites​

Step 1: Install the SDK​

pip install faos

Step 2: Set Your API Key​

Store your API key as an environment variable:

export FAOS_API_KEY="sk-your-api-key-here"
Never hardcode API keys

Always use environment variables or a secrets manager. Never commit keys to version control.

Step 3: Create a Client​

import os
from faos import FaosClient

client = FaosClient(api_key=os.environ["FAOS_API_KEY"])

Step 4: Invoke an Agent​

Use a shortcut command to invoke an agent. Shortcuts follow the pattern <module> <agent>:

import asyncio

async def main():
async with FaosClient(api_key=os.environ["FAOS_API_KEY"]) as client:
# Invoke the Banking Credit Analyst
response = await client.shortcut("bank credit-analyst")
print(response.content)

asyncio.run(main())

Step 5: Explore Available Shortcuts​

List what agents are available in a module:

shortcuts = await client.shortcuts.list(module="faos-bank")
for s in shortcuts:
print(f"{s.pattern}: {s.description}")

Step 6: Stream Responses​

For real-time output, use streaming:

async for chunk in client.shortcut_stream("health patient-intake"):
print(chunk, end="", flush=True)

Step 7: Handle Errors​

from faos import ShortcutNotFoundError, ShortcutRateLimitError

try:
response = await client.shortcut("unknown agent")
except ShortcutNotFoundError as e:
print(f"Not found: {e.command}")
print(f"Suggestions: {e.suggestions}")
except ShortcutRateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after}s")

What's Next?​