Skip to main content

Fireworks

This page covers how to use Fireworks models within Langchain.

Installation and setup​

  • Install the Fireworks integration package.

    pip install langchain-fireworks
  • Get a Fireworks API key by signing up at fireworks.ai.

  • Authenticate by setting the FIREWORKS_API_KEY environment variable.

Authentication​

There are two ways to authenticate using your Fireworks API key:

  1. Setting the FIREWORKS_API_KEY environment variable.

    os.environ["FIREWORKS_API_KEY"] = "<KEY>"
  2. Setting api_key field in the Fireworks LLM module.

    llm = Fireworks(api_key="<KEY>")

Using the Fireworks LLM module​

Fireworks integrates with Langchain through the LLM module. In this example, we will work the mixtral-8x7b-instruct model.

from langchain_fireworks import Fireworks 

llm = Fireworks(
api_key="<KEY>",
model="accounts/fireworks/models/mixtral-8x7b-instruct",
max_tokens=256)
llm("Name 3 sports.")
API Reference:Fireworks

For a more detailed walkthrough, see here.


Was this page helpful?


You can also leave detailed feedback on GitHub.