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

# Querying text models

> Fireworks.ai offers an OpenAI-compatible REST API for querying text models. There are several ways to interact with it

* The [Fireworks Python client library](https://fireworksai.readme.io/reference/installation)
* The [web console](https://app.fireworks.ai)
* [LangChain](https://python.langchain.com/docs/integrations/providers/fireworks)
* Directly invoking the [REST API](https://fireworksai.readme.io/reference/createcompletion) using your favorite tools or language
* The [OpenAI Python client](https://github.com/openai/openai-python)

## Using the web console

All Fireworks models can be accessed through the web console at [https://app.fireworks.ai/](https://app.fireworks.ai/). Clicking on a model will take you to the playground where you can enter a prompt along with additional request parameters.

Non-chat models will use the [completions API](/reference/createcompletion) which passes your input directly into the model.

Models with a conversation config are considered chat models (also known as instruct models). By default, chat models will use the [chat completions API](/reference/createchatcompletion) which will automatically format your input with the conversation style of the model. Advanced users can revert back to the completions API by unchecking the "Use chat template" option.

## Using the API

### Completions API

Text models generate text based on the provided input prompt. All text models support this basic [completions API](/reference/createcompletion). Using this API, the model will successively generate new tokens until either the maximum number of output tokens has been reached or if the model's special end-of-sequence (EOS) token has been generated.

<Note>Llama-family models will automatically prepend the beginning-of-sequence (BOS) token (\<s>) to your prompt input. This is to be consistent with the [original implementation](https://github.com/facebookresearch/llama/blob/ef351e9cd9496c579bf9f2bb036ef11bdc5ca3d2/llama/generation.py#L264).</Note>

Here are some examples of calling the completions API:

<CodeGroup>
  ```python Python (Fireworks)
  from fireworks.client import Fireworks

  client = Fireworks(api_key="<FIREWORKS_API_KEY>")
  response = client.completions.create(
    model="accounts/fireworks/models/llama-v2-7b",
    prompt="Say this is a test",
  )

  print(response.choices[0].text)
  ```

  ```python Python (OpenAI 1.x)
  import openai

  client = openai.OpenAI(
      base_url = "https://api.fireworks.ai/inference/v1",
      api_key="<FIREWORKS_API_KEY>",
  )
  response = client.completions.create(
    model="accounts/fireworks/models/llama-v2-7b",
    prompt="Say this is a test",
  )
  print(response.choices[0].text)
  ```

  ```python Python (OpenAI 0.x)cURL
  import openai

  openai.api_base = "https://api.fireworks.ai/inference/v1"
  openai.api_key = "<FIREWORKS_API_KEY>"

  response = openai.Completion.create(
    model="accounts/fireworks/models/llama-v2-7b",
    prompt="Say this is a test",
  )
  print(response.choices[0].text)
  ```

  ```bash cURL
  curl \
    --header 'Authorization: Bearer <FIREWORKS_API_KEY>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "accounts/fireworks/models/llama-v2-7b",
      "prompt": "Say this is a test"
  }' \
    --url https://api.fireworks.ai/inference/v1/completions
  ```
</CodeGroup>

### Chat Completions API

Models with a conversation config have the [chat completions API](/reference/createchatcompletion) enabled. These models are typically tuned with a specific conversation styles for which they perform best. For example Llama chat models use the following [template](https://gpus.llm-utils.org/llama-2-prompt-template/):

> \<s>\[INST] \<\<SYS>>\
> \{system\_prompt}\
> \<\</SYS>>
>
> \{user\_message\_1} \[/INST]

Some templates like `llama-chat` can support multiple chat messages as well. In general, we recommend users use the chat completions API whenever possible to avoid common prompt formatting errors. Even small errors like misplaced whitespace may result in poor model performance.

Here are some examples of calling the chat completions API:
