Skip to content

Pricing

get_pricing(service) async

Returns the current pricing configuration for models (embeddings and generative).

Prices are in USD per 1000 tokens.

Parameters:

  • service (Annotated[PricingService, Depends(get_pricing_service)]) –

    The pricing service instance injected by FastAPI.

Returns:

  • PricingMapResponse ( PricingMapResponse ) –

    A dictionary containing the pricing for different models.

Raises:

  • TechnicalError

    If there's an error retrieving the pricing configuration.

Source code in app/api/v1/endpoints/pricing.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@router.get("/", response_model=PricingMapResponse, summary="Get current model pricing")
async def get_pricing(
    service: Annotated[PricingService, Depends(get_pricing_service)],
) -> PricingMapResponse:
    """
    Returns the current pricing configuration for models (embeddings and generative).

    Prices are in USD per 1000 tokens.

    Args:
        service: The pricing service instance injected by FastAPI.

    Returns:
        PricingMapResponse: A dictionary containing the pricing for different models.

    Raises:
        TechnicalError: If there's an error retrieving the pricing configuration.
    """
    try:
        return await service.get_pricing_map()

    except Exception as e:
        logger.error(f"❌ FAIL | get_pricing | Error: {str(e)}", exc_info=True)
        raise TechnicalError(
            message=f"Failed to retrieve pricing: {e}",
            error_code="PRICING_FETCH_ERROR",
        )