Halfred Python SDK
Official Halfred SDK for Python applications with modern features, type hints, and easy integration.
Installation
pip install halfredpoetry add halfredQuick Start
Basic Setup
from halfred import Halfred
client = Halfred(api_key="halfred_xxxxxxxxxxxxxxxxxxxxxxxxxxxx")
completion = client.chat.completions.create(
model="standard",
messages=[
{"role": "user", "content": "What is the capital of France?"}
]
)
print(completion.choices[0].message.content)With Environment Variables
Chat Completions
Simple Completion
With System Message
Conversation History
With Options
Choosing a Model Profile
Response Format
JSON Mode
JSON Schema Mode
Error Handling
Type Hints Support
Streaming Responses (Coming Soon)
List Available Models
Best Practices
1. Use Environment Variables
2. Handle Errors Gracefully
3. Choose the Right Profile
4. Monitor Token Usage
Troubleshooting
Package Not Found
Import Errors
API Key Issues
Support
Next Steps
Last updated