There is an in-progress PR for converting to AnthropicMessages
https://github.com/vercel/ai/pull/8314
On the whole I think we're pretty far away from a robust solution for this problem though
For calculating the input tokens of text-only prompts, you can pass the text to the tokenizer for your given provider. Anthropic and OpenAI tokenize text differently but as an estimate I think you'll be pretty close either way. This needs to include the system prompt, and due to prompt caching you can consider it a pessimistic estimate especially if you often send prompts with similar beginnings
https://www.npmjs.com/package/@anthropic-ai/tokenizer
Images are a different story as they aren't tokenized like text. Some providers do flat rates per image, while IIRC claude charges a base rate times the megapixels for your image. That may lead you to think you can estimate the image input costs by multiplying the dimensions, but that will also be a pessimistic estimate as Anthropic resizes images before processing.
Output tokens are pretty much impossible to predict deterministically, especially when tool calls are allowed. The model may call the same tool multiple times or not at all. Some models output a lot of reasoning tokens before they reply and others don't.
The best way to predict token usage for an app is then statistical methods based on a dataset you compile of past inputs and the reported output tokens that were spent, once you have a history
Or you forgo tool calls, limit steps, and explicitly use single prompt generations where you can base your estimate on the max output tokens possible