Skip to main content

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

Metadata

Release files for hexgenerative 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hexgenerative 1.1.0
File Size Uploaded Provenance
hexgenerative-1.1.0.tar.gz 8.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for hexgenerative 1.1.0
File Interpreter ABI Platform
hexgenerative-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.2 kB

Release files / hexgenerative-1.1.0.tar.gz

Download URL hexgenerative-1.1.0.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1a23ca22e00179b6b0522c9df09123247df3034664e16087dbd00fb2327dc8f7
BLAKE2b-256 checksum
How to use checksums
dcb4e00b2c8faa80828eee3d5cb6732c84838682ae3271cd11ed7c6e6caafcd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / hexgenerative-1.1.0-py3-none-any.whl

Download URL hexgenerative-1.1.0-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac3867de60195941498456b930e15be70548f60b840e3eca33fc3988663c04ac
BLAKE2b-256 checksum
How to use checksums
46b018cee7da199fd07001fa8ecb13c7232760e0db5c1e602d68f04972b7f196
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for hexgenerative 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page