Python SDK
Install and use the Fruxon Python SDK to execute agents programmatically
The Fruxon Python SDK lets you execute agents from your Python code and from the command line.
Installation
pip install fruxonAuthentication
You need an API key and your tenant identifier. Generate an API key from your Settings page.
Python Client
from fruxon import FruxonClient
client = FruxonClient(api_key="frx_...", tenant="acme-corp")
result = client.execute("support-agent", parameters={"question": "How do I reset my password?"})
print(result.response)Execution Result
The execute() method returns an ExecutionResult with these fields:
| Field | Type | Description |
|---|---|---|
response | str | The agent's text response |
session_id | str | Session ID for multi-turn conversations |
execution_record_id | str | Unique ID for this execution |
trace | ExecutionTrace | Cost and performance metadata |
links | list | Related links returned by the agent |
The trace object contains:
| Field | Type | Description |
|---|---|---|
agent_id | str | Agent identifier |
agent_revision | int | Revision number used |
duration | int | Execution time in milliseconds |
input_cost | float | Input token cost (USD) |
output_cost | float | Output token cost (USD) |
total_cost | float | Total cost (USD) |
Multi-Turn Conversations
Pass the session_id from a previous result to continue a conversation:
result = client.execute("support-agent", parameters={"question": "What's your return policy?"})
# Continue the conversation
follow_up = client.execute(
"support-agent",
parameters={"question": "What about international orders?"},
session_id=result.session_id,
)Error Handling
The SDK raises typed exceptions for different error scenarios:
from fruxon import FruxonClient
from fruxon.exceptions import AuthenticationError, NotFoundError, FruxonConnectionError
client = FruxonClient(api_key="frx_...", tenant="acme-corp")
try:
result = client.execute("my-agent", parameters={"input": "Hello"})
except AuthenticationError:
print("Invalid API key")
except NotFoundError:
print("Agent not found")
except FruxonConnectionError:
print("Could not reach the Fruxon API")| Exception | When |
|---|---|
AuthenticationError | Invalid or missing API key (401) |
ForbiddenError | Insufficient permissions (403) |
NotFoundError | Agent or tenant not found (404) |
ValidationError | Invalid parameters (400/422) |
FruxonConnectionError | Network error |
CLI
The SDK also installs a fruxon command for running agents from the terminal.
Execute an Agent
fruxon run <agent> --tenant <tenant> --api-key <key>You can set the API key as an environment variable instead:
export FRUXON_API_KEY=frx_...
fruxon run my-agent -t acme-corpPass Parameters
fruxon run my-agent -t acme-corp -p question="Hello" -p lang=enJSON Output
Use --json to get the full response as JSON, useful for scripting:
fruxon run my-agent -t acme-corp --jsonExport a Code Agent
If you've built an agent in Python using LangChain, CrewAI, Google ADK, or another framework, you can consolidate it into a single file for importing into Fruxon:
# Auto-detect and copy to clipboard
fruxon export --copy
# Write to file
fruxon export -o export.pyfruxon export scans your project for framework imports, traces all local dependencies using Python's AST, and outputs a single consolidated file.