Documentation Index
Fetch the complete documentation index at: https://docs.muxx.dev/llms.txt
Use this file to discover all available pages before exploring further.
This guide shows how to add Muxx to an existing application with minimal changes.
Before You Start
You’ll need:
- A Muxx account
- Your Muxx API key
- 5 minutes
Gateway Migration (Fastest)
The gateway approach requires just a base URL change.
Before
from openai import OpenAI
client = OpenAI() # Uses api.openai.com
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}]
)
After
from openai import OpenAI
client = OpenAI(
base_url="https://gateway.muxx.dev/v1",
default_headers={
"X-Muxx-Api-Key": "muxx_sk_live_xxxxxxxxxxxx"
}
)
# Everything else stays the same!
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}]
)
Changes required: 2 lines
SDK Migration
For deeper tracing, use the SDK wrapper.
Before
from openai import OpenAI
client = OpenAI()
def summarize(text: str) -> str:
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": f"Summarize: {text}"}]
)
return response.choices[0].message.content
After
from muxx import Muxx
from openai import OpenAI
muxx = Muxx()
client = muxx.wrap(OpenAI()) # Wrap the client
def summarize(text: str) -> str:
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": f"Summarize: {text}"}]
)
return response.choices[0].message.content
Changes required: 3 lines (import, init, wrap)
Adding Traces
Once migrated, optionally add traces for better organization:
from muxx import Muxx, trace
from openai import OpenAI
muxx = Muxx()
client = muxx.wrap(OpenAI())
@trace("document-processing")
def process_document(doc: str) -> dict:
summary = summarize(doc)
entities = extract_entities(doc)
return {"summary": summary, "entities": entities}
def summarize(text: str) -> str:
response = client.chat.completions.create(...)
return response.choices[0].message.content
def extract_entities(text: str) -> list:
response = client.chat.completions.create(...)
return parse_entities(response)
Environment Variables
Store keys in environment variables:
# .env
OPENAI_API_KEY=sk-...
MUXX_API_KEY=muxx_sk_live_...
from muxx import Muxx
from openai import OpenAI
# Both read from environment automatically
muxx = Muxx()
client = muxx.wrap(OpenAI())
Rollback Plan
If you need to rollback:
- Gateway: Remove base_url and headers
- SDK: Remove muxx.wrap() call
Your application will work as before, just without Muxx logging.
Gradual Migration
Migrate gradually by project or feature:
- Start with non-critical features
- Verify logs appear in dashboard
- Expand to more features
- Enable for production
Troubleshooting
Logs not appearing
- Check API key is correct
- Verify project has provider keys configured
- Check network allows gateway.muxx.dev
Increased latency
- Gateway adds minimal overhead
- Enable caching for repeated queries
- Check if rate limited