Honcho AI Python SDK

2.1.1 · active · verified Fri Apr 17

The official Python SDK for Honcho AI, designed for an optimized developer experience. It provides convenient access to Honcho's AI models, including chat completions and other services. The current version is 2.1.1, and it follows an active release cadence with regular updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart initializes the Honcho client using an API key from an environment variable and makes a simple chat completion request. Replace the model name with an appropriate one if 'llama-3.8b-plastic-v2' is not available or desired.

import os
from honcho.client import Honcho

# Ensure HONCHO_API_KEY is set in your environment
# Alternatively, pass api_key directly: api_key="your_api_key"
api_key = os.environ.get('HONCHO_API_KEY', '')

if not api_key:
    raise ValueError("HONCHO_API_KEY environment variable not set.")

client = Honcho(api_key=api_key)

try:
    response = client.chat.completions.create(
        messages=[{"role": "user", "content": "What is the capital of France?"}],
        model="llama-3.8b-plastic-v2" # Or another available model like 'mixtral-8x7b-plastic-v2'
    )
    print(response.choices[0].message.content)
except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →