Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

[Feat]: Update Pricing for Google AI Studio and fix attributes (#407)

patcher9d41cfd249ebe
diff --git a/assets/pricing.json b/assets/pricing.json
index 4645e400..a07c80f7 100644
--- a/assets/pricing.json
+++ b/assets/pricing.json
@@ -270,6 +270,18 @@
"promptPrice": 0.0188,
"completionPrice": 0.0188
},
+ "gemini-1.0-pro": {
+ "promptPrice": 0.0005,
+ "completionPrice": 0.0015
+ },
+ "gemini-1.5-flash": {
+ "promptPrice": 0.000075,
+ "completionPrice": 0.0003
+ },
+ "gemini-1.5-pro": {
+ "promptPrice": 0.0035,
+ "completionPrice": 0.0105
+ },
"gemini-1.0-pro-002": {
"promptPrice": 0.0005,
"completionPrice": 0.0015
diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml
index 6628d8bf..57fe9e15 100644
--- a/sdk/python/pyproject.toml
+++ b/sdk/python/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openlit"
-version = "1.20.0"
+version = "1.21.0"
description = "OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects"
authors = ["OpenLIT"]
repository = "https://github.com/openlit/openlit/tree/main/openlit/python"
diff --git a/sdk/python/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py b/sdk/python/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py
index 39ab49a2..8f456a8c 100644
--- a/sdk/python/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py
+++ b/sdk/python/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py
@@ -1,6 +1,6 @@
# pylint: disable=duplicate-code, broad-exception-caught, too-many-statements, unused-argument, possibly-used-before-assignment, protected-access
"""
-Module for monitoring Ollama API calls.
+Module for monitoring Google AI Studio API calls.
"""
import logging
@@ -24,9 +24,9 @@ def async_generate(gen_ai_endpoint, version, environment, application_name,
gen_ai_endpoint: Endpoint identifier for logging and tracing.
version: Version of the monitoring package.
environment: Deployment environment (e.g., production, staging).
- application_name: Name of the application using the Ollama API.
+ application_name: Name of the application using the Google AI Studio API.
tracer: OpenTelemetry tracer for creating spans.
- pricing_info: Information used for calculating the cost of Ollama usage.
+ pricing_info: Information used for calculating the cost of Google AI Studio usage.
trace_content: Flag indicating whether to trace the actual content.
Returns:
@@ -81,10 +81,12 @@ def async_generate(gen_ai_endpoint, version, environment, application_name,
model = instance._model_id
if hasattr(instance, "_model_name"):
model = instance._model_name.replace("publishers/google/models/", "")
+ if model.startswith("models/"):
+ model = model[len("models/"):]
total_tokens = input_tokens + output_tokens
# Calculate cost of the operation
- cost = get_chat_model_cost(kwargs.get("model", "gpt-3.5-turbo"),
+ cost = get_chat_model_cost(model,
pricing_info, input_tokens,
output_tokens)
@@ -174,6 +176,8 @@ def async_generate(gen_ai_endpoint, version, environment, application_name,
model = instance._model_id
if hasattr(instance, "_model_name"):
model = instance._model_name.replace("publishers/google/models/", "")
+ if model.startswith("models/"):
+ model = model[len("models/"):]
# Set base span attribues
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
@@ -210,7 +214,7 @@ def async_generate(gen_ai_endpoint, version, environment, application_name,
completion_tokens = response.usage_metadata.candidates_token_count
total_tokens = response.usage_metadata.total_token_count
# Calculate cost of the operation
- cost = get_chat_model_cost(kwargs.get("model", "llama3"),
+ cost = get_chat_model_cost(model,
pricing_info, prompt_tokens, completion_tokens)
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_PROMPT_TOKENS,
@@ -231,13 +235,13 @@ def async_generate(gen_ai_endpoint, version, environment, application_name,
SemanticConvetion.GEN_AI_APPLICATION_NAME:
application_name,
SemanticConvetion.GEN_AI_SYSTEM:
- SemanticConvetion.GEN_AI_SYSTEM_OLLAMA,
+ SemanticConvetion.GEN_AI_SYSTEM_GOOGLE_AI_STUDIO,
SemanticConvetion.GEN_AI_ENVIRONMENT:
environment,
SemanticConvetion.GEN_AI_TYPE:
SemanticConvetion.GEN_AI_TYPE_CHAT,
SemanticConvetion.GEN_AI_REQUEST_MODEL:
- kwargs.get("model", "llama3")
+ model
}
metrics["genai_requests"].add(1, attributes)
diff --git a/sdk/python/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py b/sdk/python/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py
index 0af908ab..ac02e7e0 100644
--- a/sdk/python/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py
+++ b/sdk/python/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py
@@ -1,6 +1,6 @@
# pylint: disable=duplicate-code, broad-exception-caught, too-many-statements, unused-argument, possibly-used-before-assignment, protected-access
"""
-Module for monitoring Ollama API calls.
+Module for monitoring Google AI Studio API calls.
"""
import logging
@@ -24,9 +24,9 @@ def generate(gen_ai_endpoint, version, environment, application_name,
gen_ai_endpoint: Endpoint identifier for logging and tracing.
version: Version of the monitoring package.
environment: Deployment environment (e.g., production, staging).
- application_name: Name of the application using the Ollama API.
+ application_name: Name of the application using the Google AI Studio API.
tracer: OpenTelemetry tracer for creating spans.
- pricing_info: Information used for calculating the cost of Ollama usage.
+ pricing_info: Information used for calculating the cost of Google AI Studio usage.
trace_content: Flag indicating whether to trace the actual content.
Returns:
@@ -81,10 +81,12 @@ def generate(gen_ai_endpoint, version, environment, application_name,
model = instance._model_id
if hasattr(instance, "_model_name"):
model = instance._model_name.replace("publishers/google/models/", "")
+ if model.startswith("models/"):
+ model = model[len("models/"):]
total_tokens = input_tokens + output_tokens
# Calculate cost of the operation
- cost = get_chat_model_cost(kwargs.get("model", "gpt-3.5-turbo"),
+ cost = get_chat_model_cost(model,
pricing_info, input_tokens,
output_tokens)
@@ -176,6 +178,8 @@ def generate(gen_ai_endpoint, version, environment, application_name,
model = instance._model_id
if hasattr(instance, "_model_name"):
model = instance._model_name.replace("publishers/google/models/", "")
+ if model.startswith("models/"):
+ model = model[len("models/"):]
# Set base span attribues
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
@@ -212,7 +216,7 @@ def generate(gen_ai_endpoint, version, environment, application_name,
completion_tokens = response.usage_metadata.candidates_token_count
total_tokens = response.usage_metadata.total_token_count
# Calculate cost of the operation
- cost = get_chat_model_cost(kwargs.get("model", "llama3"),
+ cost = get_chat_model_cost(model,
pricing_info, prompt_tokens, completion_tokens)
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_PROMPT_TOKENS,
@@ -233,13 +237,13 @@ def generate(gen_ai_endpoint, version, environment, application_name,
SemanticConvetion.GEN_AI_APPLICATION_NAME:
application_name,
SemanticConvetion.GEN_AI_SYSTEM:
- SemanticConvetion.GEN_AI_SYSTEM_OLLAMA,
+ SemanticConvetion.GEN_AI_SYSTEM_GOOGLE_AI_STUDIO,
SemanticConvetion.GEN_AI_ENVIRONMENT:
environment,
SemanticConvetion.GEN_AI_TYPE:
SemanticConvetion.GEN_AI_TYPE_CHAT,
SemanticConvetion.GEN_AI_REQUEST_MODEL:
- kwargs.get("model", "llama3")
+ model
}
metrics["genai_requests"].add(1, attributes)