The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
from typing import Final
from integration.cost_calculation.cost_tracking_case import (
CostTrackingTestCase,
Deployment,
ExactExpected,
JsonResponse,
SseResponse,
)
from integration.cost_calculation.stream_parity.bases.openai_responses import (
GPT_6_1_SOL_RESPONSES,
GPT_6_1_SOL_RESPONSES_PARITY_STREAM_RESPONSE,
)
from integration.cost_calculation.stream_parity.case import COVERS, MODEL, REQUEST_ID, StreamParityTestCase, sse_frames
_USAGE: Final = {"prompt_tokens": 30, "completion_tokens": 40, "total_tokens": 70}
_CHUNK: Final = {
"id": f"chatcmpl-{REQUEST_ID}",
"object": "chat.completion.chunk",
"created": 1,
"model": "gpt-6.1-sol",
}
GPT_6_1_SOL_CHAT_COMPLETIONS: Final = CostTrackingTestCase(
name="gpt-6.1-sol-chat-parity",
covers=COVERS,
model="gpt-6.1-sol",
endpoint="/v1/chat/completions",
deployment=Deployment(input_cost_per_token=0.001, output_cost_per_token=0.002),
request={"model": MODEL, "messages": [{"role": "user", "content": "Say hello."}], "cache": {"no-cache": True}},
response=JsonResponse(
content_type="application/json",
body={
"id": f"chatcmpl-{REQUEST_ID}",
"object": "chat.completion",
"created": 1,
"model": "gpt-6.1-sol",
"choices": [{"index": 0, "message": {"role": "assistant", "content": "Hello."}, "finish_reason": "stop"}],
"usage": _USAGE,
},
),
expected=ExactExpected(spend=0.11, input_cost=0.03, output_cost=0.08, prompt_tokens=30, completion_tokens=40),
)
GPT_6_1_SOL_CHAT_COMPLETIONS_PARITY: Final = StreamParityTestCase(
plain=GPT_6_1_SOL_CHAT_COMPLETIONS,
streamed=GPT_6_1_SOL_CHAT_COMPLETIONS.model_copy(
update={
"name": "gpt-6.1-sol-chat-parity-stream",
"request": {
**GPT_6_1_SOL_CHAT_COMPLETIONS.request,
"stream": True,
"stream_options": {"include_usage": True},
},
"response": SseResponse(
content_type="text/event-stream",
frames=sse_frames(
{**_CHUNK, "choices": [{"index": 0, "delta": {"role": "assistant", "content": "Hello."}}]},
{**_CHUNK, "choices": [{"index": 0, "delta": {}, "finish_reason": "stop"}]},
{**_CHUNK, "choices": [], "usage": _USAGE},
done=True,
),
),
}
),
)
GPT_6_1_SOL_MESSAGES: Final = GPT_6_1_SOL_RESPONSES.model_copy(
update={
"name": "gpt-6.1-sol-messages-parity",
"model": "gpt-6.1-sol",
"endpoint": "/v1/messages",
"request": {
"model": MODEL,
"max_tokens": 64,
"messages": [{"role": "user", "content": "Say hello."}],
"cache": {"no-cache": True},
},
}
)
GPT_6_1_SOL_MESSAGES_PARITY: Final = StreamParityTestCase(
plain=GPT_6_1_SOL_MESSAGES,
streamed=GPT_6_1_SOL_MESSAGES.model_copy(
update={
"name": "gpt-6.1-sol-messages-parity-stream",
"request": {**GPT_6_1_SOL_MESSAGES.request, "stream": True},
"response": GPT_6_1_SOL_RESPONSES_PARITY_STREAM_RESPONSE,
}
),
)