Fallbakit SDKs
Python SDK
Install and use the PyPI package with explicit API key and base URL configuration.
Install
pip install fallbakitConfigure
The SDK constructor requires an API key. Keep the key in your environment variables or secret manager, then pass it explicitly.
import os
from fallbakit import Fallbakit
client = Fallbakit(
api_key=os.environ["FALLBAKIT_API_KEY"],
base_url=os.environ.get("FALLBAKIT_BASE_URL", "https://api.fallbakit.com"),
timeout=30,
)Chat completion
response = client.chat.completions.create(
model="llama3.2",
messages=[{"role": "user", "content": "Write a short welcome message"}],
extra_body={
"fallbakit": {
"fallbackProvider": "openai",
"fallbackModel": "gpt-4o-mini",
"fallback": True,
}
},
)
print(response["choices"][0]["message"]["content"])Streaming
for chunk in client.chat.completions.create(
model="llama3.2",
messages=[{"role": "user", "content": "Stream one sentence"}],
stream=True,
):
delta = chunk["choices"][0].get("delta", {})
print(delta.get("content", ""), end="")The SDK yields chunks as they arrive and does not buffer the full response.