Prompt is too long 203073 tokens > 200000 maximum

Author: fitchmultzCreated Jan 12, 2025Updated Jan 13, 2025

Description

When making API requests, receiving a 400 error due to prompt length exceeding maximum token limit.

Error Message

Error in _get_completion: Error code: 400
{'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'prompt is too long: 203073 tokens > 200000 maximum'}}

Expected Behavior

API requests should process successfully within token limits

Current Behavior

Request fails because prompt length (203,073 tokens) exceeds maximum allowed tokens (200,000)

Steps to Reproduce

  1. Make API request with prompt
  2. Receive 400 error due to token limit

Possible Solutions

  1. Reduce prompt length to stay under 200k token limit
  2. Break large prompts into smaller chunks
  3. Implement token counting check before making request

Additional Context

Token limits are a known constraint of the API. Need to implement proper handling.

Labels

  • bug
  • api
  • token-limit

Source: Doriandarko/claude-engineer