---
title: "Discussion on \"Counting OpenAI Tokens per Request in FastAPI — Without Touching My Use Cases\" | Hashnode"
description: "Discussion on \"Counting OpenAI Tokens per Request in FastAPI — Without Touching My Use Cases\". Structured logging for a Clean Architecture RAG service, and the ContextVar trap I had to design around"
url: "https://hashnode.com/posts/counting-openai-tokens-per-request-in-fastapi-without-touching-my-use-cases/6ad373d6a480dabb84c1855b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Counting OpenAI Tokens per Request in FastAPI — Without Touching My Use Cases](https://yusufoztoprak.hashnode.dev/counting-openai-tokens-per-request-in-fastapi-without-touching-my-use-cases?utm_source=hashnode&utm_medium=feed)

Structured logging for a Clean Architecture RAG service, and the ContextVar trap I had to design around

Oct 17 · 7 min read · yusufoztoprak.hashnode.dev  
Read the article

## Written by

[Yusuf Öztoprak](https://hashnode.com/@yusufoztoprak)

@yusufoztoprak · Istanbul, Turkey

  
[View profile](https://hashnode.com/@yusufoztoprak)

Backend Engineer | AI Infrastructure (RAG · pgvector · LLM APIs)

Backend Engineer building AI infrastructure — RAG, pgvector, LLM APIs.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
