Skip to main content
Use Moonshot models with Hypertic agent.

Installation

Install the OpenAI package (Moonshot uses OpenAI-compatible API):
pip install hypertic[openai]

Setup

Set your Moonshot API key as an environment variable:
export MOONSHOT_API_KEY=...

Initialize Model

Create a Moonshot model instance:
from hypertic.models import MoonshotAI
import os

model = MoonshotAI(
    api_key=os.getenv("MOONSHOT_API_KEY"),
    model="moonshot-v1-8k",
)

Use with Agent

Pass the model to your agent:
from hypertic.agents import Agent
from hypertic.models import MoonshotAI
import os

model = MoonshotAI(
    api_key=os.getenv("MOONSHOT_API_KEY"),
    model="moonshot-v1-8k",
)
agent = Agent(
    model=model,
    tools=[get_weather],
)

response = agent.run("What's the weather in SF?")
print(response.content)

Configuration Options

Supported parameters for Moonshot models:
from hypertic.models import MoonshotAI
import os

model = MoonshotAI(
    api_key=os.getenv("MOONSHOT_API_KEY"),
    model="moonshot-v1-8k",
    temperature=0.7,
    max_tokens=1000,
)
For the full list of available models and parameters, see the Moonshot API documentation.