# ChatFireworks

> **Class** in `langchain_fireworks`

📖 [View in docs](https://reference.langchain.com/python/langchain-fireworks/chat_models/ChatFireworks)

`Fireworks` Chat large language models API.

To use, you should have the
environment variable `FIREWORKS_API_KEY` set with your API key.

Any parameters that are valid to be passed to the fireworks.create call
can be passed in, even if not explicitly saved on this class.

## Signature

```python
ChatFireworks()
```

## Description

**Example:**

```python
from langchain_fireworks.chat_models import ChatFireworks

model = ChatFireworks(model_name="accounts/fireworks/models/gpt-oss-120b")
```

Fireworks request headers can be passed with `extra_headers`. For prompt
caching, `x-session-affinity` pins requests to a replica so related calls can
reuse the same prompt-cache session:

```python
model.invoke(
    "Hello",
    extra_headers={"x-session-affinity": "user-42"},
)
```

The Fireworks SDK also accepts a typed `prompt_cache_key` field (passed as a
regular keyword argument), which it treats as the preferred alternative to
the raw `x-session-affinity` header:

```python
model.invoke("Hello", prompt_cache_key="user-42")
```

## Extends

- `BaseChatModel`

## Properties

- `lc_secrets`
- `lc_attributes`
- `client`
- `async_client`
- `model_name`
- `model`
- `temperature`
- `stop`
- `model_kwargs`
- `fireworks_api_key`
- `fireworks_api_base`
- `request_timeout`
- `streaming`
- `stream_usage`
- `n`
- `max_tokens`
- `max_retries`
- `service_tier`
- `reasoning_effort`
- `model_config`

## Methods

- [`get_lc_namespace()`](https://reference.langchain.com/python/langchain-fireworks/chat_models/ChatFireworks/get_lc_namespace)
- [`is_lc_serializable()`](https://reference.langchain.com/python/langchain-fireworks/chat_models/ChatFireworks/is_lc_serializable)
- [`build_extra()`](https://reference.langchain.com/python/langchain-fireworks/chat_models/ChatFireworks/build_extra)
- [`validate_environment()`](https://reference.langchain.com/python/langchain-fireworks/chat_models/ChatFireworks/validate_environment)
- [`close()`](https://reference.langchain.com/python/langchain-fireworks/chat_models/ChatFireworks/close)
- [`aclose()`](https://reference.langchain.com/python/langchain-fireworks/chat_models/ChatFireworks/aclose)
- [`bind_tools()`](https://reference.langchain.com/python/langchain-fireworks/chat_models/ChatFireworks/bind_tools)
- [`with_structured_output()`](https://reference.langchain.com/python/langchain-fireworks/chat_models/ChatFireworks/with_structured_output)

---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/40956c3882857050f32e3617a4776612acb827b6/libs/partners/fireworks/langchain_fireworks/chat_models.py#L715)