Vai al contenuto
NotHolyDocs

Riferimento API

Messages (Anthropic)

POST /v1/messages nel formato Anthropic Messages, usato dagli SDK Anthropic e da Claude Code.

Vedi in Markdown

Richiesta e risposta di Anthropic Messages sui modelli NotHoly. Gli SDK Anthropic prendono https://api.notholy.com come URL base, senza /v1. Funzionano sia x-api-key sia Authorization: Bearer.

POSThttps://api.notholy.com/v1/messages

Richiesta

CampoTipoObbligatorioNote
modelstringSìUn ID di modello, per esempio notholy-specter
max_tokensnumberSìMaggiore di 0. Limitato all'output massimo del modello
messagesarraySìTurni user e assistant con blocchi text, image, tool_use e tool_result. Sono accettati anche turni system tra i messaggi
systemstring o arrayNoSolo blocchi di testo
toolsarrayNoI tuoi strumenti con input_schema. Gli strumenti lato server, come la ricerca web, vengono saltati
tool_choiceobjectNoauto, any, none o {"type": "tool", "name": …}
thinkingobjectNo{"type": "enabled", "budget_tokens": N} o {"type": "adaptive"} attiva il ragionamento
output_config.effortstringNoLivello di ragionamento; prevale su thinking. Viene portato al livello più vicino che il modello ha
stop_sequences, temperature, top_pNoPassati al modello
streambooleanNotrue restituisce eventi di stream Anthropic

POST /v1/messages/count_tokens accetta lo stesso corpo e restituisce {"input_tokens": n}, una stima fatta senza chiamare il modello.

Risposta senza streaming

JSON
{
  "id": "msg_3Jd8a",
  "type": "message",
  "role": "assistant",
  "model": "notholy-specter",
  "content": [
    { "type": "thinking", "thinking": "…", "signature": "nh" },
    { "type": "text", "text": "A Sigma rule is a generic detection rule in YAML…" }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": { "input_tokens": 24, "output_tokens": 131, "cache_read_input_tokens": 0, "cache_creation_input_tokens": 0 }
}
  • stop_reason è end_turn, max_tokens o tool_use.
  • I blocchi thinking che rimandi nella cronologia vengono scartati prima che il modello li veda.
  • cache_control viene accettato e ignorato.
  • Le fonti document PDF e file restituiscono 400 unsupported_parameter. Manda i file tramite la chat o POST /v1/files.
  • In uno stream, le chiamate di strumenti arrivano intere: un solo input_json_delta con gli argomenti completi. Le pause lunghe ricevono eventi ping.

Esempio

curl https://api.notholy.com/v1/messages \
  -H "x-api-key: $NOTHOLY_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model": "notholy-specter", "max_tokens": 512, "messages": [{"role": "user", "content": "What is a Sigma rule?"}]}'

Conta i token prima di inviare:

curl
curl https://api.notholy.com/v1/messages/count_tokens \
  -H "x-api-key: $NOTHOLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "notholy-specter", "messages": [{"role": "user", "content": "What is a Sigma rule?"}]}'

Errori

Gli errori usano la forma di Anthropic, {"type": "error", "error": {"type", "message"}}: invalid_request_error (400) · authentication_error (401) · billing_error (402) · permission_error (403) · not_found_error (404) · rate_limit_error (429) · request_too_large (413) · api_error (500, 502, 504) · overloaded_error (503). Vedi Errori.