Aller au contenu

OpenAI SDK

Pointez un SDK OpenAI vers l’URL de base Hermes et appelez des LLM avec votre clé API Hermes.

Set the base URL and key

The chat endpoint is OpenAI-compatible, so the official OpenAI SDK works without changes. Create an API key, export it as HERMES_API_KEY, and create the client with the base URL https://api.hermes-ai.net/api/v1.

shell
npm install openai
# or
pip install openai

export HERMES_API_KEY=your_api_key

Créez une clé d’API

Send a chat completion

Streaming, function tools, JSON mode and reasoning settings pass through unchanged.

curl https://api.hermes-ai.net/api/v1/chat/completions \
  -H "Authorization: Bearer $HERMES_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-4.5",
    "messages": [{"role": "user", "content": "Say hello in one sentence."}],
    "max_tokens": 200
  }'

Choose a model ID

GET /api/v1/chat/models lists the LLMs you can call, with prices in USD per 1M tokens. Use an id from that list as model. GET /api/v1/models is the image, video and music catalog, not the chat model list.

shell
curl https://api.hermes-ai.net/api/v1/chat/models

Browse LLMs

Billing and errors

Each request reserves credits for the estimated prompt plus max_tokens, then charges the usage the model reports and releases the rest. Set max_tokens to keep reservations small. Errors use the OpenAI error object with a documented Hermes code.

Chat completions (LLM)Codes d’erreur

Image, video and music models

These models run as asynchronous tasks through POST /api/v1/jobs, not through the OpenAI SDK. Tâches et résultats