Official Python SDK for Hexa AI - Lightning-Fast AI API
Project description
Hexa Generative AI - Python SDK
Official Python client for Hexa AI API.
Installation
pip install hexgenerative
Quick Start
from hexgenerative import HexaAI
# Initialize client
client = HexaAI(api_key="hgx-your-api-key")
# Create chat completion
response = client.chat.completions.create(
model="hexa-pro",
messages=[
{"role": "user", "content": "Explain quantum computing in simple terms"}
]
)
print(response.choices[0].message.content)
Available Models
| Model | Description | Best For |
|---|---|---|
hexa-instant |
Fastest model | Quick responses, simple tasks |
hexa-balanced |
General purpose | Most use cases |
hexa-reasoning |
Deep analysis | Complex reasoning |
hexa-advanced |
Coding expert | Programming tasks |
hexa-pro |
Premium quality | Best results |
hexa-vision-scout |
Vision model | Image understanding |
Smart Routing
Let Hexa AI pick the best model automatically:
# By task type
response = client.chat.completions.create(
task="coding",
messages=[{"role": "user", "content": "Write a Python function"}]
)
# By optimization preference
response = client.chat.completions.create(
optimize_for="speed",
messages=[{"role": "user", "content": "Quick answer please"}]
)
# Full auto-select
response = client.chat.completions.create(
auto_select=True,
messages=[{"role": "user", "content": "Your message"}]
)
Async Support
import asyncio
from hexgenerative import HexaAI
client = HexaAI(api_key="hgx-your-api-key")
async def main():
response = await client.chat.completions.acreate(
model="hexa-pro",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
asyncio.run(main())
Error Handling
from hexgenerative import HexaAI
from hexgenerative.client import HexaAIError
client = HexaAI(api_key="hgx-your-api-key")
try:
response = client.chat.completions.create(
model="hexa-pro",
messages=[{"role": "user", "content": "Hello"}]
)
except HexaAIError as e:
print(f"Error: {e.message}")
print(f"Status: {e.status_code}")
Agentic Features
Agents (Beta)
Run complex tasks with autonomous agents.
result = client.agent.run(
task="Research the latest AI trends",
model="hexa-ultra"
)
print(result["result"])
RAG (Knowledge Base)
High-accuracy retrieval augmented generation.
# Upload document
client.rag.upload(
title="Company Policy",
content="Employees get 30 days of leave..."
)
# Search
results = client.rag.search(query="leave policy")
Context Management (300K Tokens)
Manage massive context sessions.
# Create session
session = client.context.create(system_prompt="You are a helpful assistant")
session_id = session["data"]["session_id"]
# Add message
client.context.add(
session_id=session_id,
message={"role": "user", "content": "..."}
)
Tools & Code Execution
# List tools
tools = client.tools.list()
# Execute Code
result = client.code.execute(code="print(10 + 20)")
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hexgenerative-1.1.0.tar.gz
(8.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hexgenerative-1.1.0.tar.gz.
File metadata
- Download URL: hexgenerative-1.1.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a23ca22e00179b6b0522c9df09123247df3034664e16087dbd00fb2327dc8f7
|
|
| MD5 |
bdbbd47437a706490d86e7e0a7f2abcd
|
|
| BLAKE2b-256 |
dcb4e00b2c8faa80828eee3d5cb6732c84838682ae3271cd11ed7c6e6caafcd7
|
File details
Details for the file hexgenerative-1.1.0-py3-none-any.whl.
File metadata
- Download URL: hexgenerative-1.1.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac3867de60195941498456b930e15be70548f60b840e3eca33fc3988663c04ac
|
|
| MD5 |
c8d349ff3763adae59890c0e0074d346
|
|
| BLAKE2b-256 |
46b018cee7da199fd07001fa8ecb13c7232760e0db5c1e602d68f04972b7f196
|