AI 지출 마스터하기: OneRouter 사용 회계 가이드
OneRouter 사용 회계
By 앤드류 젱 •
OneRouter 사용 회계



2025. 12. 12.
앤드류 젱
OneRouter API는 추가 API 호출 없이 AI 모델 사용량을 추적할 수 있는 사용량 회계 기능을 제공합니다. 이 기능은 API 응답에서 토큰 수, 비용 및 캐싱 상태에 대한 자세한 정보를 제공합니다.
활성화되면 API는 다음을 포함한 자세한 사용량 정보를 반환합니다:
모델의 기본 토크나이저를 사용한 프롬프트 및 완료 토큰 수
크레딧 비용
이유 토큰 수(해당되는 경우)
캐시된 토큰 수(사용 가능한 경우)
이 정보는 스트리밍 응답의 마지막 SSE 메시지 또는 비스트리밍 요청의 전체 응답에 포함됩니다.
요청에 usage 매개변수를 포함하여 사용량 회계를 활성화할 수 있습니다:
{ "model": "your-model", "usage": { "include": true } }
사용량 회계가 활성화되면, 응답에는 자세한 토큰 정보와 cost 항목 및 상세 비용이 포함된 cost_details 객체가 포함됩니다:
{ "id": "c4942c8a-39d8-d39e-7eb0-395c4e4dbf68", "choices": [ { "finish_reason": "stop", "index": 0, "logprobs": null, "message": { "content": "**Paris** is the capital of France. It's the largest city in the country, serving as the political, cultural, and economic center, with a population of about 2.1 million in the city proper and over 12 million in the greater metropolitan area. This has been the case since the 10th century, when Hugh Capet established it as the seat of the Capetian dynasty.", "refusal": null, "role": "assistant", "annotations": null, "audio": null, "function_call": null, "tool_calls": null } } ], "created": 1763949831, "model": "grok-4-1-fast-non-reasoning", "object": "chat.completion", "service_tier": null, "system_fingerprint": "fp_80e0751284", "usage": { "completion_tokens": 80, "prompt_tokens": 175, "total_tokens": 255, "completion_tokens_details": { "accepted_prediction_tokens": 0, "audio_tokens": 0, "reasoning_tokens": 0, "rejected_prediction_tokens": 0 }, "prompt_tokens_details": { "audio_tokens": 0, "cached_tokens": 161, "image_tokens": 0, "text_tokens": 175 }, "num_sources_used": 0 }, "cost": 0.000051, "cost_details": { "audio_cost": 0, "cache_prompt_cost": 8.05e-6, "cache_write_cost": 0, "generation_cost": 0, "image_cost": 0, "input_prompt_cost": 2.8e-6, "output_prompt_cost": 0.00004, "tools_cost": 0, "video_cost": 0 }, "request_id": "e7d2ff652d84410f903aef33d7f6471e" }
cost는 귀하의 계정에 청구된 총 금액입니다.
cost_details는 총 비용의 세부 사항입니다.
사용량 회계를 활성화하면 API가 토큰 수 및 비용을 계산하는 데 몇 백 밀리초가 추가되어 마지막 응답에 영향을 미칩니다. 이는 최종 메시지에만 영향을 미치며 전체 스트리밍 성능에는 영향을 미치지 않습니다.
효율성: 별도의 API 호출 없이 사용량 정보 획득
정확성: 토큰 수는 모델의 기본 토크나이저를 사용하여 계산됨
투명성: 실시간으로 비용 및 캐시된 토큰 사용 추적
자세한 분류: 프롬프트, 완료, 이유 및 캐시된 토큰에 대한 별도의 수치
토큰 소비 또는 비용을 모니터링해야 할 때 사용량 추적 활성화
사용량 회계가 활성화된 경우 최종 응답의 약간의 지연을 고려
개발에서 사용량 추적 구현을 고려하여 생산 이전에 토큰 사용 최적화
응용 프로그램 성능 최적화를 위해 캐시된 토큰 정보를 사용
from openai import OpenAI client = OpenAI( base_url="https://llm.onerouter.pro/v1", api_key="{{API_KEY_REF}}", ) response = client.chat.completions.create( model="{{MODEL}}", messages=[ {"role": "user", "content": "What is the capital of France?"} ], extra_body={ "usage": { "include": True } } ) print("Response:", response.choices[0].message.content) print("Usage Stats:", getattr(response, "usage", None))
OpenAI 사양에 따르면, 스트리밍 응답에서 토큰 사용량 정보를 요청하기 위해 요청에 다음 매개변수를 포함해야 합니다:
{ "model": "gemini-2.5-flash", "messages": [ { "role": "user", "content": "hi" } ], "stream": true, "stream_options": { "include_usage": true } }
이 구성은 API에게 다음과 같은 작업을 하도록 지시합니다:
Gemini 2.5 Flash 모델 사용
응답을 점진적으로 스트리밍
스트림 응답에 토큰 사용 통계 포함
stream_options.include_usage 매개변수는 스트리밍 응답의 일부로 토큰 사용 정보를 반환하도록 특별히 요청합니다.
사용량 회계를 구현하는 방법을 마스터했으니, 이 기능 뒤에 있는 전략적 가치와 엔지니어링 능력을 이해하기 위해 한 걸음 물러나 보십시오. 우리는 다음의 심층 기사들을 추천합니다:
AI API 비용 관리의 미래 – 사용량 투명성이 더 나은 비즈니스 결정을 유도하는 방법을 알아보세요.
실시간 비용 추적: 기술적 기반 – OneRouter의 회계 엔진을 지원하는 인프라를 살펴보세요.
OneRouter API는 추가 API 호출 없이 AI 모델 사용량을 추적할 수 있는 사용량 회계 기능을 제공합니다. 이 기능은 API 응답에서 토큰 수, 비용 및 캐싱 상태에 대한 자세한 정보를 제공합니다.
활성화되면 API는 다음을 포함한 자세한 사용량 정보를 반환합니다:
모델의 기본 토크나이저를 사용한 프롬프트 및 완료 토큰 수
크레딧 비용
이유 토큰 수(해당되는 경우)
캐시된 토큰 수(사용 가능한 경우)
이 정보는 스트리밍 응답의 마지막 SSE 메시지 또는 비스트리밍 요청의 전체 응답에 포함됩니다.
요청에 usage 매개변수를 포함하여 사용량 회계를 활성화할 수 있습니다:
{ "model": "your-model", "usage": { "include": true } }
사용량 회계가 활성화되면, 응답에는 자세한 토큰 정보와 cost 항목 및 상세 비용이 포함된 cost_details 객체가 포함됩니다:
{ "id": "c4942c8a-39d8-d39e-7eb0-395c4e4dbf68", "choices": [ { "finish_reason": "stop", "index": 0, "logprobs": null, "message": { "content": "**Paris** is the capital of France. It's the largest city in the country, serving as the political, cultural, and economic center, with a population of about 2.1 million in the city proper and over 12 million in the greater metropolitan area. This has been the case since the 10th century, when Hugh Capet established it as the seat of the Capetian dynasty.", "refusal": null, "role": "assistant", "annotations": null, "audio": null, "function_call": null, "tool_calls": null } } ], "created": 1763949831, "model": "grok-4-1-fast-non-reasoning", "object": "chat.completion", "service_tier": null, "system_fingerprint": "fp_80e0751284", "usage": { "completion_tokens": 80, "prompt_tokens": 175, "total_tokens": 255, "completion_tokens_details": { "accepted_prediction_tokens": 0, "audio_tokens": 0, "reasoning_tokens": 0, "rejected_prediction_tokens": 0 }, "prompt_tokens_details": { "audio_tokens": 0, "cached_tokens": 161, "image_tokens": 0, "text_tokens": 175 }, "num_sources_used": 0 }, "cost": 0.000051, "cost_details": { "audio_cost": 0, "cache_prompt_cost": 8.05e-6, "cache_write_cost": 0, "generation_cost": 0, "image_cost": 0, "input_prompt_cost": 2.8e-6, "output_prompt_cost": 0.00004, "tools_cost": 0, "video_cost": 0 }, "request_id": "e7d2ff652d84410f903aef33d7f6471e" }
cost는 귀하의 계정에 청구된 총 금액입니다.
cost_details는 총 비용의 세부 사항입니다.
사용량 회계를 활성화하면 API가 토큰 수 및 비용을 계산하는 데 몇 백 밀리초가 추가되어 마지막 응답에 영향을 미칩니다. 이는 최종 메시지에만 영향을 미치며 전체 스트리밍 성능에는 영향을 미치지 않습니다.
효율성: 별도의 API 호출 없이 사용량 정보 획득
정확성: 토큰 수는 모델의 기본 토크나이저를 사용하여 계산됨
투명성: 실시간으로 비용 및 캐시된 토큰 사용 추적
자세한 분류: 프롬프트, 완료, 이유 및 캐시된 토큰에 대한 별도의 수치
토큰 소비 또는 비용을 모니터링해야 할 때 사용량 추적 활성화
사용량 회계가 활성화된 경우 최종 응답의 약간의 지연을 고려
개발에서 사용량 추적 구현을 고려하여 생산 이전에 토큰 사용 최적화
응용 프로그램 성능 최적화를 위해 캐시된 토큰 정보를 사용
from openai import OpenAI client = OpenAI( base_url="https://llm.onerouter.pro/v1", api_key="{{API_KEY_REF}}", ) response = client.chat.completions.create( model="{{MODEL}}", messages=[ {"role": "user", "content": "What is the capital of France?"} ], extra_body={ "usage": { "include": True } } ) print("Response:", response.choices[0].message.content) print("Usage Stats:", getattr(response, "usage", None))
OpenAI 사양에 따르면, 스트리밍 응답에서 토큰 사용량 정보를 요청하기 위해 요청에 다음 매개변수를 포함해야 합니다:
{ "model": "gemini-2.5-flash", "messages": [ { "role": "user", "content": "hi" } ], "stream": true, "stream_options": { "include_usage": true } }
이 구성은 API에게 다음과 같은 작업을 하도록 지시합니다:
Gemini 2.5 Flash 모델 사용
응답을 점진적으로 스트리밍
스트림 응답에 토큰 사용 통계 포함
stream_options.include_usage 매개변수는 스트리밍 응답의 일부로 토큰 사용 정보를 반환하도록 특별히 요청합니다.
사용량 회계를 구현하는 방법을 마스터했으니, 이 기능 뒤에 있는 전략적 가치와 엔지니어링 능력을 이해하기 위해 한 걸음 물러나 보십시오. 우리는 다음의 심층 기사들을 추천합니다:
AI API 비용 관리의 미래 – 사용량 투명성이 더 나은 비즈니스 결정을 유도하는 방법을 알아보세요.
실시간 비용 추적: 기술적 기반 – OneRouter의 회계 엔진을 지원하는 인프라를 살펴보세요.
OneRouter 사용 회계
By 앤드류 젱 •