Skip to content

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]

695 B
Raw Blame
import pytest


pytestmark = pytest.mark.asyncio(loop_scope="session")


async def test_key_generate_lands_in_db(gateway_client, db, resources):
    from litellm.proxy.utils import hash_token

    resp = await gateway_client.post(
        "/key/generate",
        headers={"Authorization": f"Bearer {gateway_client.gateway.key}"},
        json={"key_alias": resources.prefix},
    )
    assert resp.status_code == 200, resp.text
    cleartext = resp.json()["key"]
    assert cleartext.startswith("sk-")

    hashed = hash_token(cleartext)
    row = await db.db.litellm_verificationtoken.find_unique(where={"token": hashed})
    assert row is not None
    assert row.token == hashed != cleartext