> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langchain.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ChatFireworks integration

> Integrate with the ChatFireworks chat model using LangChain JavaScript.

[Fireworks AI](https://fireworks.ai/) is an AI inference platform to run and customize models. For a list of all models served by Fireworks see the [Fireworks docs](https://fireworks.ai/models).

This guide will help you getting started with `ChatFireworks` [chat models](https://docs.langchain.com/oss/javascript/langchain/models.md). For detailed documentation of all `ChatFireworks` features and configurations head to the [API reference](https://reference.langchain.com/javascript/langchain-fireworks/ChatFireworks).

## Overview

### Integration details

| Class | Package | Serializable | [PY support](https://docs.langchain.com/oss/python/integrations/chat/fireworks) | Downloads | Version |
| :- | :- | :-: | :-: | :-: | :-: |
| [`ChatFireworks`](https://reference.langchain.com/javascript/langchain-fireworks/ChatFireworks) | [`@langchain/fireworks`](https://www.npmjs.com/package/@langchain/fireworks) | ✅ | ✅ | ![NPM - Downloads](https://img.shields.io/npm/dm/@langchain/fireworks?style=flat-square\&label=%20&) | ![NPM - Version](https://img.shields.io/npm/v/@langchain/fireworks?style=flat-square\&label=%20&) |

### Model features

See the links in the table headers below for guides on how to use specific features.

| [Tool calling](https://docs.langchain.com/oss/javascript/langchain/tools.md) | [Structured output](https://docs.langchain.com/oss/javascript/langchain/structured-output.md) | [Image input](https://docs.langchain.com/oss/javascript/langchain/messages.md#multimodal) | Audio input | Video input | [Token-level streaming](https://docs.langchain.com/oss/javascript/langchain/streaming.md) | [Token usage](https://docs.langchain.com/oss/javascript/langchain/models.md#token-usage) | [Logprobs](https://docs.langchain.com/oss/javascript/langchain/models.md#log-probabilities) |
| :-: | :-: | :-: | :-: | :-: | :-: | :-: | :-: |
| ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |

## Setup

To access `ChatFireworks` models you'll need to create a Fireworks account, get an API key, and install the `@langchain/fireworks` integration package.

### Credentials

Head to [the Fireworks website](https://fireworks.ai/login) to sign up to Fireworks and generate an API key. Once you've done this set the `FIREWORKS_API_KEY` environment variable:

```bash theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
export FIREWORKS_API_KEY="your-api-key"
```

If you want to get automated tracing of your model calls you can also set your [LangSmith](https://docs.langchain.com/langsmith/observability.md) API key by uncommenting below:

```bash theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
# export LANGSMITH_TRACING="true"
# export LANGSMITH_API_KEY="your-api-key"
```

### Installation

The LangChain `ChatFireworks` integration lives in the `@langchain/fireworks` package:

```bash npm theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
npm install @langchain/fireworks @langchain/core
```

```bash yarn theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
yarn add @langchain/fireworks @langchain/core
```

```bash pnpm theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
pnpm add @langchain/fireworks @langchain/core
```

## Instantiation

Now we can instantiate our model object and generate chat completions:

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { ChatFireworks } from "@langchain/fireworks"

const llm = new ChatFireworks({
    model: "accounts/fireworks/models/llama-v3p1-70b-instruct",
    temperature: 0,
    maxTokens: undefined,
    timeout: undefined,
    maxRetries: 2,
    // other params...
})
```

## Invocation

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
const aiMsg = await llm.invoke([
    [
        "system",
        "You are a helpful assistant that translates English to French. Translate the user sentence.",
    ],
    ["human", "I love programming."],
])
aiMsg
```

```text theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
AIMessage {
  "id": "chatcmpl-9rBYHbb6QYRrKyr2tMhO9pH4AYXR4",
  "content": "J'adore la programmation.",
  "additional_kwargs": {},
  "response_metadata": {
    "tokenUsage": {
      "completionTokens": 8,
      "promptTokens": 31,
      "totalTokens": 39
    },
    "finish_reason": "stop"
  },
  "tool_calls": [],
  "invalid_tool_calls": [],
  "usage_metadata": {
    "input_tokens": 31,
    "output_tokens": 8,
    "total_tokens": 39
  }
}
```

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
console.log(aiMsg.content)
```

```text theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
J'adore la programmation.
```

***

## API reference

For detailed documentation of all `ChatFireworks` features and configurations head to the [API reference](https://reference.langchain.com/javascript/langchain-fireworks/ChatFireworks).

***

[Connect these docs](https://docs.langchain.com/use-these-docs.md) to your agent of choice via MCP for real-time answers.

[Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/chat/fireworks.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
