I Was Calling Models. I Found This

A curios journey in AI on AWS Bedrock

One account and many models. What Is Bedrock?

Amazon Bedrock is a fully managed AWS service that gives you access to foundation models from multiple providers Anthropic, Google, Amazon, and more. You access models by simply referencing a model ID like amazon.nova-micro-v1:0 and pay per request directly through your AWS bill. Read docs about Anthropic case 😊.

For this project I picked Amazon Nova Micro Amazon’s own lightweight text model.

FinOps Concern: If I Start a Business

Getting a model running is exciting. Paying an unexpected $800 bill at the end of the month is not. Before writing your business logic with LLM. I recommend you to set up cost allocation: tagging Lambda functions and making sure every Bedrock call was traceable. When you’re building a product, knowing which feature consumed how many tokens is mandatory.

LLM (Large Language Model) literacy

The four parameters appear across every LLM, sometimes with different names or casing (maxTokens in Claude, max_new_tokens in Nova):

  • maxTokens hard cap on output length. Set it or risk runaway responses and runaway bills.
  • temperature controls randomness. 0.2 for precise answers, 0.9 for creative generation.
  • topP nucleus sampling. The model only considers tokens whose cumulative probability reaches this threshold. Keeps outputs coherent without being robotic.
  • topK limits the candidate pool to the top K most likely tokens. A lower value like 20 produces focused, predictable text.

I need to monitor my cost

Every invocation has a cost. Without visibility, you’re flying blind.

I integrated AWS Lambda Powertools (Logger) to emit structured JSON logs to CloudWatch on every request: prompt length, token counts, latency, and a calculated cost estimate per call. With a single CloudWatch Insights query you can surface your most expensive prompts in seconds and optimize before costs scale. Important is simple to add this module by layers.

So I get this:

a clear picture:

Full code is in my heart. I’m joking is in a GitHub Gist 🔗The super api nova invocation. Feel free to study it

Reading more docs How to take care of wallet. I found the classic techique the powerfull tagging and then easily you can find in billing dashboard your usage cost. Here is an example.

Conclusion: The Adventure

Combining theory with hours of applied practice is where the real learning lives. 🤘

👉models response body

👉aws powertools for logging

👉invocattion model

Oftoppic

A dog is not a toy/gift. A dog is a part of a family.

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy