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

# Workflow Setup

> How to setup workflows

![Workflow Example](https://lytix-cdn.s3.amazonaws.com/documentationAssets/workflows/workflowExampleGif.gif)

Workflows are ways to group and analyze your LLM data. Not all calls to a given model should be evaluated the same way, so workflows allow you to define different evaluation criteria for different models.

In addition to high level metrics, workflows also allow you to define custom evaluation criteria that you can use to evaluate your LLM data.

# Setup A Workflow

Workflows are created when data is first pushed and tagged with a given workflow name. There are two ways to create a workflow:

#### Use an API Key

Use an API key to automatically push data to a workflow. Learn more [here](/APIKeys/api-keys-and-workflows).

#### Use [Optimodel](/Quickstart/optimodel-getting-started) to push data to a workflow (see code below)

<CodeGroup>
  ```py Python
  from optimodel import queryModel, ModelTypes, ModelMessage, ModelMessageContentEntry

  response = await queryModel(
      # Just set this field
      workflowName="test-workflow", 
      model=ModelTypes.llama_3_70b_instruct,
      messages=[
          ModelMessage(
              role="system",
              content="Always respond with a JSON object",
          ),
          ModelMessage(role="user", content=[
              ModelMessageContentEntry(type="text", text="Hello how are you again?"),
          ]),
      ],
  )
  ```

  ```py Typescript
  import { queryModel, ModelTypes } from "@lytix/client";

  const main = async () => {
    const prompt = "Hello How are you?";
    const response = await queryModel({
      model: ModelTypes.gpt_4o_mini,
      messages: [
        { role: "user", content: prompt },
        { role: "system", content: "Always respond with a JSON object" },
      ],
      workflowName="test-workflow"
    });
    console.log(`Got response: ${response}`);
  };
  ```
</CodeGroup>

#### Use the native OpenAI client to push data to a workflow

<CodeGroup>
  ```py Python
  response = client.chat.completions.create(
      model=ModelTypes.mistral_large_latest.name,
      temperature=0,
      max_tokens=1000,
      messages=[
          {"role": "system", "content": "You are a helpful assistant. Always JSON"},
          {"role": "user", "content": "How are you?"},
      ],
      extra_headers={
          # Set this field
          "workflowName": "Example workflow"
      }
  )
  ```

  ```js Typescript
  const response = await client.chat.completions.create(
    {
      messages: [{ role: "user", content: "Hello world" }],
      model: "gpt-4",
    },
    {
      headers: {
        // Add your workflowName to track workflows
        "workflowName": "test-workflow",
      },
    }
  );
  ```
</CodeGroup>
