This commit is contained in:
Edward 2026-10-28 13:12:16 +00:00 • committed by GitHub
commit 9ff2c03ea1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 557 additions and 0 deletions

View file

@ -1056,6 +1056,7 @@ openai_compatible_endpoints: Final[list[str]] = [
"https://pinstripes.io/v1",
"https://api.meta.ai/v1",
"https://api.sailresearch.com/v1",
"https://api.tokenify.dev/v1",
"https://api.cognition.ai/v1",
"https://inference.coralbricks.ai/v1",
"https://api.cortecs.ai/v1",
@ -1144,6 +1145,7 @@ openai_compatible_providers: Final[list[str]] = [
"prism",
"sail",
"reka",
"tokenify",
]
OPENAI_AUDIO_TRANSCRIPTION_PROVIDERS: Final = frozenset({"openai"} | frozenset(openai_compatible_providers))

View file

@ -263,5 +263,11 @@
"/v1/chat/completions",
"/v1/responses"
]
},
"tokenify": {
"base_url": "https://api.tokenify.dev/v1",
"api_key_env": "TOKENIFY_API_KEY",
"api_base_env": "TOKENIFY_API_BASE",
"supported_endpoints": ["/v1/chat/completions", "/v1/responses", "/v1/messages"]
}
}

View file

@ -76331,6 +76331,126 @@
"max"
]
},
"tokenify/deepseek/deepseek-v4-flash": {
"cache_read_input_token_cost": 1.4e-08,
"input_cost_per_token": 2.2e-07,
"litellm_provider": "tokenify",
"max_input_tokens": 1048576,
"max_output_tokens": 393216,
"mode": "chat",
"output_cost_per_token": 6.6e-07,
"source": "https://www.tokenify.dev/pricing/",
"supported_endpoints": [
"/v1/chat/completions",
"/v1/responses",
"/v1/messages"
],
"supports_function_calling": true,
"supports_native_streaming": true,
"supports_parallel_function_calling": true,
"supports_prompt_caching": true,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true,
"supports_vision": false
},
"tokenify/deepseek/deepseek-v4-pro": {
"cache_read_input_token_cost": 4.4e-08,
"input_cost_per_token": 6.6e-07,
"litellm_provider": "tokenify",
"max_input_tokens": 1048576,
"max_output_tokens": 393216,
"mode": "chat",
"output_cost_per_token": 1.98e-06,
"source": "https://www.tokenify.dev/pricing/",
"supported_endpoints": [
"/v1/chat/completions",
"/v1/responses",
"/v1/messages"
],
"supports_function_calling": true,
"supports_native_streaming": true,
"supports_parallel_function_calling": true,
"supports_prompt_caching": true,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true,
"supports_vision": false
},
"tokenify/deepseek/deepseek-v4.1-flash": {
"cache_read_input_token_cost": 6e-09,
"input_cost_per_token": 1.5e-07,
"litellm_provider": "tokenify",
"max_input_tokens": 1048576,
"max_output_tokens": 393216,
"mode": "chat",
"output_cost_per_token": 6e-07,
"source": "https://www.tokenify.dev/pricing/",
"supported_endpoints": [
"/v1/chat/completions",
"/v1/responses",
"/v1/messages"
],
"supports_function_calling": true,
"supports_native_streaming": true,
"supports_parallel_function_calling": true,
"supports_prompt_caching": true,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true,
"supports_vision": true
},
"tokenify/z-ai/glm-5.2": {
"cache_read_input_token_cost": 2.6e-07,
"input_cost_per_token": 7e-07,
"litellm_provider": "tokenify",
"max_input_tokens": 1048576,
"max_output_tokens": 131072,
"mode": "chat",
"output_cost_per_token": 2.2e-06,
"source": "https://www.tokenify.dev/pricing/",
"supported_endpoints": [
"/v1/chat/completions",
"/v1/responses",
"/v1/messages"
],
"supports_function_calling": true,
"supports_native_streaming": true,
"supports_parallel_function_calling": true,
"supports_prompt_caching": true,
"supports_reasoning": true,
"supports_response_schema": false,
"supports_system_messages": true,
"supports_tool_choice": true,
"supports_vision": false
},
"tokenify/z-ai/glm-5.3-flash": {
"cache_read_input_token_cost": 3e-08,
"input_cost_per_token": 1.5e-07,
"litellm_provider": "tokenify",
"max_input_tokens": 1048576,
"max_output_tokens": 131072,
"mode": "chat",
"output_cost_per_token": 5e-07,
"source": "https://www.tokenify.dev/pricing/",
"supported_endpoints": [
"/v1/chat/completions",
"/v1/responses",
"/v1/messages"
],
"supports_function_calling": true,
"supports_native_streaming": true,
"supports_parallel_function_calling": true,
"supports_prompt_caching": true,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true,
"supports_vision": true
},
"bedrock_mantle/openai.gpt-6.1-terra": {
"cache_creation_input_token_cost": 1.375e-06,
"cache_creation_input_token_cost_above_272k_tokens": 2.75e-06,

View file

@ -1061,6 +1061,32 @@
"generateContent": false
}
},
"tokenify": {
"display_name": "Tokenify (`tokenify`)",
"url": "https://docs.litellm.ai/docs/providers/tokenify",
"endpoints": {
"chat_completions": true,
"responses": true,
"text_completion": true,
"embeddings": false,
"image_generations": false,
"image_edits": false,
"audio_transcriptions": false,
"audio_speech": false,
"rerank": false,
"ocr": false,
"search": false,
"moderations": false,
"realtime": false,
"video_generations": false,
"batches": false,
"messages": true,
"interactions": true,
"systemone": false,
"a2a": true,
"generateContent": true
}
},
"crusoe": {
"display_name": "Crusoe (`crusoe`)",
"url": "https://docs.litellm.ai/docs/providers/crusoe",

View file

@ -1173,6 +1173,34 @@
],
"default_model_placeholder": "cortecs/gpt-6-sol"
},
{
"provider": "TOKENIFY",
"provider_display_name": "Tokenify",
"litellm_provider": "tokenify",
"credential_fields": [
{
"key": "api_base",
"label": "API Base",
"placeholder": "https://api.tokenify.dev/v1",
"tooltip": null,
"required": false,
"field_type": "text",
"options": null,
"default_value": null
},
{
"key": "api_key",
"label": "API Key",
"placeholder": null,
"tooltip": null,
"required": true,
"field_type": "password",
"options": null,
"default_value": null
}
],
"default_model_placeholder": "tokenify/deepseek/deepseek-v4-pro"
},
{
"provider": "CUSTOM",
"provider_display_name": "Custom",

View file

@ -4590,6 +4590,7 @@ class LlmProviders(str, Enum):
META = "meta"
SAIL = "sail"
REKA = "reka"
TOKENIFY = "tokenify"
LITELLM_AGENT = "litellm_agent"
CURSOR = "cursor"
BEDROCK_MANTLE = "bedrock_mantle"

View file

@ -76331,6 +76331,126 @@
"max"
]
},
"tokenify/deepseek/deepseek-v4-flash": {
"cache_read_input_token_cost": 1.4e-08,
"input_cost_per_token": 2.2e-07,
"litellm_provider": "tokenify",
"max_input_tokens": 1048576,
"max_output_tokens": 393216,
"mode": "chat",
"output_cost_per_token": 6.6e-07,
"source": "https://www.tokenify.dev/pricing/",
"supported_endpoints": [
"/v1/chat/completions",
"/v1/responses",
"/v1/messages"
],
"supports_function_calling": true,
"supports_native_streaming": true,
"supports_parallel_function_calling": true,
"supports_prompt_caching": true,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true,
"supports_vision": false
},
"tokenify/deepseek/deepseek-v4-pro": {
"cache_read_input_token_cost": 4.4e-08,
"input_cost_per_token": 6.6e-07,
"litellm_provider": "tokenify",
"max_input_tokens": 1048576,
"max_output_tokens": 393216,
"mode": "chat",
"output_cost_per_token": 1.98e-06,
"source": "https://www.tokenify.dev/pricing/",
"supported_endpoints": [
"/v1/chat/completions",
"/v1/responses",
"/v1/messages"
],
"supports_function_calling": true,
"supports_native_streaming": true,
"supports_parallel_function_calling": true,
"supports_prompt_caching": true,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true,
"supports_vision": false
},
"tokenify/deepseek/deepseek-v4.1-flash": {
"cache_read_input_token_cost": 6e-09,
"input_cost_per_token": 1.5e-07,
"litellm_provider": "tokenify",
"max_input_tokens": 1048576,
"max_output_tokens": 393216,
"mode": "chat",
"output_cost_per_token": 6e-07,
"source": "https://www.tokenify.dev/pricing/",
"supported_endpoints": [
"/v1/chat/completions",
"/v1/responses",
"/v1/messages"
],
"supports_function_calling": true,
"supports_native_streaming": true,
"supports_parallel_function_calling": true,
"supports_prompt_caching": true,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true,
"supports_vision": true
},
"tokenify/z-ai/glm-5.2": {
"cache_read_input_token_cost": 2.6e-07,
"input_cost_per_token": 7e-07,
"litellm_provider": "tokenify",
"max_input_tokens": 1048576,
"max_output_tokens": 131072,
"mode": "chat",
"output_cost_per_token": 2.2e-06,
"source": "https://www.tokenify.dev/pricing/",
"supported_endpoints": [
"/v1/chat/completions",
"/v1/responses",
"/v1/messages"
],
"supports_function_calling": true,
"supports_native_streaming": true,
"supports_parallel_function_calling": true,
"supports_prompt_caching": true,
"supports_reasoning": true,
"supports_response_schema": false,
"supports_system_messages": true,
"supports_tool_choice": true,
"supports_vision": false
},
"tokenify/z-ai/glm-5.3-flash": {
"cache_read_input_token_cost": 3e-08,
"input_cost_per_token": 1.5e-07,
"litellm_provider": "tokenify",
"max_input_tokens": 1048576,
"max_output_tokens": 131072,
"mode": "chat",
"output_cost_per_token": 5e-07,
"source": "https://www.tokenify.dev/pricing/",
"supported_endpoints": [
"/v1/chat/completions",
"/v1/responses",
"/v1/messages"
],
"supports_function_calling": true,
"supports_native_streaming": true,
"supports_parallel_function_calling": true,
"supports_prompt_caching": true,
"supports_reasoning": true,
"supports_response_schema": true,
"supports_system_messages": true,
"supports_tool_choice": true,
"supports_vision": true
},
"bedrock_mantle/openai.gpt-6.1-terra": {
"cache_creation_input_token_cost": 1.375e-06,
"cache_creation_input_token_cost_above_272k_tokens": 2.75e-06,

View file

@ -1061,6 +1061,32 @@
"generateContent": false
}
},
"tokenify": {
"display_name": "Tokenify (`tokenify`)",
"url": "https://docs.litellm.ai/docs/providers/tokenify",
"endpoints": {
"chat_completions": true,
"responses": true,
"text_completion": true,
"embeddings": false,
"image_generations": false,
"image_edits": false,
"audio_transcriptions": false,
"audio_speech": false,
"rerank": false,
"ocr": false,
"search": false,
"moderations": false,
"realtime": false,
"video_generations": false,
"batches": false,
"messages": true,
"interactions": true,
"systemone": false,
"a2a": true,
"generateContent": true
}
},
"crusoe": {
"display_name": "Crusoe (`crusoe`)",
"url": "https://docs.litellm.ai/docs/providers/crusoe",

View file

@ -0,0 +1,228 @@
import json
from pathlib import Path
from typing import Final
import pytest
import respx
import litellm
from litellm.caching.llm_caching_handler import LLMClientCache
def test_tokenify_provider_resolution(monkeypatch: pytest.MonkeyPatch):
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
monkeypatch.setenv("TOKENIFY_API_KEY", "tokenify-test-key")
model, provider, api_key, api_base = get_llm_provider(
model="tokenify/deepseek/deepseek-v4-pro",
custom_llm_provider=None,
api_base=None,
api_key=None,
)
assert model == "deepseek/deepseek-v4-pro"
assert provider == "tokenify"
assert api_key == "tokenify-test-key"
assert api_base == "https://api.tokenify.dev/v1"
def test_tokenify_provider_keeps_explicit_credentials(monkeypatch: pytest.MonkeyPatch):
from litellm.litellm_core_utils.get_llm_provider_logic import get_llm_provider
monkeypatch.setenv("TOKENIFY_API_KEY", "tokenify-env-key")
_, provider, api_key, api_base = get_llm_provider(
model="tokenify/deepseek/deepseek-v4-pro",
custom_llm_provider=None,
api_base="https://tokenify.internal.example/v1",
api_key="tokenify-explicit-key",
)
assert provider == "tokenify"
assert api_key == "tokenify-explicit-key"
assert api_base == "https://tokenify.internal.example/v1"
TOKENIFY_MODELS: Final = (
"tokenify/deepseek/deepseek-v4-flash",
"tokenify/deepseek/deepseek-v4-pro",
"tokenify/deepseek/deepseek-v4.1-flash",
"tokenify/z-ai/glm-5.2",
"tokenify/z-ai/glm-5.3-flash",
)
def test_tokenify_models_are_priced():
assert tuple(sorted(name for name in litellm.model_cost if name.startswith("tokenify/"))) == TOKENIFY_MODELS
for model in TOKENIFY_MODELS:
entry = litellm.model_cost[model]
assert 0 < entry["input_cost_per_token"] <= entry["output_cost_per_token"]
@pytest.mark.parametrize("model", TOKENIFY_MODELS)
def test_tokenify_model_cost_and_capabilities(model: str):
from litellm.cost_calculator import cost_per_token
prompt_cost, completion_cost = cost_per_token(
model=model,
prompt_tokens=1_000_000,
completion_tokens=1_000_000,
custom_llm_provider="tokenify",
)
model_info = litellm.get_model_info(model)
assert (prompt_cost, completion_cost) == pytest.approx(
(
model_info["input_cost_per_token"] * 1_000_000,
model_info["output_cost_per_token"] * 1_000_000,
)
)
assert 0 < model_info["cache_read_input_token_cost"] < model_info["input_cost_per_token"]
assert 0 < model_info["max_output_tokens"] <= model_info["max_input_tokens"]
assert model_info["litellm_provider"] == "tokenify"
assert model_info["mode"] == "chat"
assert model_info["supports_function_calling"] is True
assert model_info["supports_reasoning"] is True
assert litellm.supports_vision(model) is model_info["supports_vision"]
def test_tokenify_admin_placeholder_model_is_priced():
fields_path = Path(litellm.__file__).parent / "proxy" / "public_endpoints" / "provider_create_fields.json"
providers = json.loads(fields_path.read_text())
tokenify = next(provider for provider in providers if provider["litellm_provider"] == "tokenify")
assert tokenify["default_model_placeholder"] in TOKENIFY_MODELS
def test_tokenify_backup_registry_mirrors_cost_map():
package_root = Path(litellm.__file__).parent
cost_map = json.loads((package_root.parent / "model_prices_and_context_window.json").read_text())
backup = json.loads((package_root / "model_prices_and_context_window_backup.json").read_text())
tokenify_entries = {name: entry for name, entry in cost_map.items() if name.startswith("tokenify/")}
assert tuple(sorted(tokenify_entries)) == TOKENIFY_MODELS
assert tokenify_entries == {name: backup[name] for name in tokenify_entries}
def test_tokenify_is_available_in_add_model_form():
fields_path = Path(litellm.__file__).parent / "proxy" / "public_endpoints" / "provider_create_fields.json"
providers = json.loads(fields_path.read_text())
tokenify = next(provider for provider in providers if provider["litellm_provider"] == "tokenify")
assert tokenify["provider"] == "TOKENIFY"
assert tokenify["provider_display_name"] == "Tokenify"
assert tokenify["default_model_placeholder"] == "tokenify/deepseek/deepseek-v4-pro"
assert {field["key"]: field["required"] for field in tokenify["credential_fields"]} == {
"api_base": False,
"api_key": True,
}
def test_tokenify_chat_completion_request():
with respx.mock() as upstream:
route: Final = upstream.post("https://api.tokenify.dev/v1/chat/completions").respond(
200,
json={
"id": "chatcmpl_tokenify",
"object": "chat.completion",
"created": 1_789_550_000,
"model": "deepseek/deepseek-v4-pro",
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": "Hello from Tokenify"},
"finish_reason": "stop",
}
],
"usage": {"prompt_tokens": 4, "completion_tokens": 3, "total_tokens": 7},
},
)
response: Final = litellm.completion(
model="tokenify/deepseek/deepseek-v4-pro",
messages=[{"role": "user", "content": "Say hello"}],
api_key="tokenify-test-key",
)
request: Final = route.calls.last.request
body: Final = json.loads(request.content)
assert route.call_count == 1
assert str(request.url) == "https://api.tokenify.dev/v1/chat/completions"
assert request.headers["authorization"] == "Bearer tokenify-test-key"
assert body["model"] == "deepseek/deepseek-v4-pro"
assert body["messages"] == [{"role": "user", "content": "Say hello"}]
assert response.choices[0].message.content == "Hello from Tokenify"
def test_tokenify_responses_request():
with respx.mock() as upstream:
route: Final = upstream.post("https://api.tokenify.dev/v1/responses").respond(
200,
json={
"id": "resp_tokenify",
"object": "response",
"created_at": 1_789_550_000,
"model": "deepseek/deepseek-v4-pro",
"status": "completed",
"output": [
{
"id": "msg_tokenify",
"type": "message",
"role": "assistant",
"status": "completed",
"content": [{"type": "output_text", "text": "Hello from Tokenify", "annotations": []}],
}
],
"usage": {"input_tokens": 4, "output_tokens": 3, "total_tokens": 7},
},
)
response: Final = litellm.responses(
model="tokenify/deepseek/deepseek-v4-pro",
input="Say hello",
api_key="tokenify-test-key",
)
request: Final = route.calls.last.request
body: Final = json.loads(request.content)
assert route.call_count == 1
assert str(request.url) == "https://api.tokenify.dev/v1/responses"
assert request.headers["authorization"] == "Bearer tokenify-test-key"
assert body["model"] == "deepseek/deepseek-v4-pro"
assert body["input"] == "Say hello"
assert response.output[0].content[0].text == "Hello from Tokenify"
@pytest.mark.asyncio
async def test_tokenify_anthropic_messages_request(monkeypatch: pytest.MonkeyPatch):
monkeypatch.setattr(litellm, "disable_aiohttp_transport", True)
monkeypatch.setattr(litellm, "in_memory_llm_clients_cache", LLMClientCache())
with respx.mock() as upstream:
route: Final = upstream.post("https://api.tokenify.dev/v1/messages").respond(
200,
json={
"id": "msg_tokenify",
"type": "message",
"role": "assistant",
"model": "deepseek/deepseek-v4-pro",
"content": [{"type": "text", "text": "Hello from Tokenify"}],
"stop_reason": "end_turn",
"stop_sequence": None,
"usage": {"input_tokens": 4, "output_tokens": 3},
},
)
response: Final = await litellm.anthropic.messages.acreate(
model="tokenify/deepseek/deepseek-v4-pro",
messages=[{"role": "user", "content": "Say hello"}],
max_tokens=32,
api_key="tokenify-test-key",
)
request: Final = route.calls.last.request
body: Final = json.loads(request.content)
assert route.call_count == 1
assert str(request.url) == "https://api.tokenify.dev/v1/messages"
assert request.headers["authorization"] == "Bearer tokenify-test-key"
assert request.headers["anthropic-version"] == "2023-06-01"
assert body["model"] == "deepseek/deepseek-v4-pro"
assert body["messages"] == [{"role": "user", "content": "Say hello"}]
assert response["content"][0]["text"] == "Hello from Tokenify"