# get_token_cost_for_model

> **Function** in `langchain_nvidia_ai_endpoints`

📖 [View in docs](https://reference.langchain.com/python/langchain-nvidia-ai-endpoints/callbacks/get_token_cost_for_model)

Get the cost in USD for a given model and number of tokens.

## Signature

```python
get_token_cost_for_model(
    model_name: str,
    num_tokens: int,
    price_map: dict,
    is_completion: bool = False,
) -> float
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `model_name` | `str` | Yes | Name of the model |
| `num_tokens` | `int` | Yes | Number of tokens. |
| `price_map` | `dict` | Yes | Map of model names to cost per 1000 tokens. Defaults to AI Foundation Endpoint pricing per https://www.together.ai/pricing. |
| `is_completion` | `bool` | No | Whether the model is used for completion or not. (default: `False`) |

## Returns

`float`

Cost in USD.

---

[View source on GitHub](https://github.com/langchain-ai/langchain-nvidia/blob/0f17fc4ec134f9d86ba79cbc2a2d95760953ea41/libs/ai-endpoints/langchain_nvidia_ai_endpoints/callbacks.py#L116)