POST /v1/messages/count_tokens #5

Open
opened 2026-08-03 16:55:22 -07:00 by kalmiya · 0 comments
Owner

Kanban ticket: t_337cd973
Board: hermes-anthropic-api


Task t_337cd973: POST /v1/messages/count_tokens
status: ready
assignee: -
workspace: scratch
max-retries: 2 (default)
created: 2026-08-03 16:53 by kalmiya

Body:
Anthropic token counting endpoint.

Request: same body shape as POST /v1/messages.
Response: {"input_tokens": N}

Implementation:

  • Use the same tokenizer the agent uses for prompt preparation.
  • For Hermes, this likely means calling the provider's /v1/messages/count_tokens if available, or a local estimate via the active provider's tokenizer helper.
  • Handle the case where the underlying provider doesn't expose token counting: return an anthropic_error with type invalid_request_error and HTTP 400, with a clear message naming the provider.

Events (1):
[2026-08-03 16:53] created {'assignee': None, 'status': 'ready', 'parents': [], 'tenant': None, 'workspace_kind': 'scratch', 'workspace_path': None, 'branch_name': None, 'project_id': None, 'skills': None, 'goal_mode': None, 'model_override': None, 'provider_override': None}

**Kanban ticket:** `t_337cd973` **Board:** `hermes-anthropic-api` --- Task t_337cd973: POST /v1/messages/count_tokens status: ready assignee: - workspace: scratch max-retries: 2 (default) created: 2026-08-03 16:53 by kalmiya Body: Anthropic token counting endpoint. Request: same body shape as `POST /v1/messages`. Response: `{"input_tokens": N}` Implementation: - Use the same tokenizer the agent uses for prompt preparation. - For Hermes, this likely means calling the provider's `/v1/messages/count_tokens` if available, or a local estimate via the active provider's tokenizer helper. - Handle the case where the underlying provider doesn't expose token counting: return an `anthropic_error` with type `invalid_request_error` and HTTP 400, with a clear message naming the provider. Events (1): [2026-08-03 16:53] created {'assignee': None, 'status': 'ready', 'parents': [], 'tenant': None, 'workspace_kind': 'scratch', 'workspace_path': None, 'branch_name': None, 'project_id': None, 'skills': None, 'goal_mode': None, 'model_override': None, 'provider_override': None}
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kalmiya/hermes-anthropic-api#5
No description provided.