Logo

cohere

#10147

input_limit_exceeded_error

Too many tokens: the total number of tokens in the prompt exceeds the limit of 4081. Try using a shorter prompt or enable prompt truncating. See https://docs.cohere.com/reference/generate for more details.

This error has been identified and solved.

Reason

The 400 status error you are encountering is due to the prompt exceeding the maximum allowed token limit for the Cohere API. Specifically, the error message indicates that the total number of tokens in the prompt (4796) cannot exceed 4081 tokens, which is the maximum limit set by the API.

Solution

To fix the "too many tokens" error in the Cohere API, you need to ensure that the total number of tokens in your prompt does not exceed the maximum limit of 4081 tokens. Here are some concise solutions:

  • Shorten the prompt: Reduce the length of your prompt to stay within the token limit.

  • Enable prompt truncation: Use the API's built-in prompt truncation feature to automatically truncate the prompt to fit within the limit.

  • Split the prompt: If possible, split your request into multiple smaller prompts to avoid exceeding the token limit in a single request.

  • Adjust the model parameters: Consider adjusting parameters such as max_tokens or other relevant settings to optimize the prompt and response within the allowed limits.

Original Error Message

Raw

Too many tokens: the total number of tokens in the prompt exceeds the limit of 4081. Try using a shorter prompt or enable prompt truncating. See https://docs.cohere.com/reference/generate for more details.

Original Error Message

Raw

Too many tokens: the total number of tokens in the prompt exceeds the limit of 4081. Try using a shorter prompt or enable prompt truncating. See https://docs.cohere.com/reference/generate for more details.

© 2024 Portkey, Inc. All rights reserved

HIPAA

COMPLIANT

GDPR

Transform Your AI app prototypes to be production-ready

Talk to us →