build_anthropic_client (agent/anthropic_adapter.py)

Yeachan-Heo/hermes-agent · agent/anthropic_adapter.py · python · MIT
ai

Adapter for Anthropic Messages API with multi-auth support

# Source: https://github.com/Yeachan-Heo/hermes-agent | License: MIT | Copyright 2025 Nous Research
# Provided via justclaw.it.com; keep this notice with the code.
"""Anthropic Messages API adapter for Hermes Agent.

Translates between Hermes's internal OpenAI-style message format and
Anthropic's Messages API. Follows the same pattern as the codex_responses
adapter — all provider-specific logic is isolated here.

Auth supports:
  - Regular API keys (sk-ant-api*) → x-api-key header
  - OAuth setup-tokens (sk-ant-oat*) → Bearer auth + beta header
  - Claude Code credentials (~/.claude.json or ~/.claude/.credentials.json) → Bearer auth
"""

import copy
import json
import logging
import os
from pathlib import Path

from hermes_constants import get_hermes_home
from types import SimpleNamespace


... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key