Halfred Python SDK
Official Halfred SDK for Python applications with modern features, type hints, and easy integration.
Installation
Install the Halfred SDK using pip:
pip install halfredOr with poetry:
poetry 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
Or use python-dotenv:
Chat Completions
Simple Completion
With System Message
Conversation History
With Options
Choosing a Model Profile
Halfred offers different profiles optimized for various use cases:
Learn more about profiles in our Model Profiles guide.
Response Format
JSON Mode
Request JSON-formatted responses:
JSON Schema Mode
Enforce a specific JSON structure using JSON Schema:
Error Handling
Type Hints Support
The SDK includes full type hints for better IDE support:
Streaming Responses (Coming Soon)
Real-time streaming support is coming soon. Contact support for early access.
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
Documentation: https://docs.halfred.ai
Email: support@halfred.ai
Discord: Join our community
GitHub: Report issues
Next Steps
Learn about Model Profiles
Explore the REST API Reference
Check out Best Practices
Last updated