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

# Prompting Preview API

> Lucidworks AI Prediction API

export const LwTemplate = ({title = "Key questions to get you started", icon = "sparkles", cta = "Powered by Agent Studio", linkHref = "https://lucidworks.com/demo/?utm_source=docs&utm_medium=referral&utm_campaign=docs_cta_ai"}) => {
  const [isLoaded, setIsLoaded] = useState(false);
  useEffect(() => {
    const timer = setTimeout(() => {
      setIsLoaded(true);
    }, 500);
    return () => clearTimeout(timer);
  }, []);
  return <div className="lw-template-container">
      <Card title={title} icon={icon}>
        {isLoaded && <span dangerouslySetInnerHTML={{
    __html: `<lw-template id="a029c1a9-28be-427e-b0e1-5d918920246a"></lw-template
            >`
  }} />}
        <Link href={linkHref} className="agent-studio-link text-left text-gray-600 gap-2 dark:text-gray-400 text-sm font-medium flex flex-row items-center hover:text-primary dark:hover:text-primary-light group-hover:text-primary group-hover:dark:text-primary-light">Powered by Lucidworks Agent Studio</Link>
      </Card>
    </div>;
};

[localhost link]: http://localhost:3000/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-prompting-preview-api

[mintlify link]: https://doc.lucidworks.com/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-prompting-preview-api

[old doc.lw link]: https://doc.lucidworks.com/lw-platform/ai/m0x9s2

The Lucidworks AI Generative AI Prompting Preview API returns [Prediction API `passthrough` use case](/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-prediction-api/passthrough-prediction) prompts before being sent to any [generative AI (Gen-AI) model](/docs/lw-platform/lw-ai/lw-ai-generative-ai#generative-ai-models).

This API is used to help debug `passthrough` use case prompts to ensure the input to the Gen-AI model is valid, and within the model’s processing limits.

<Note>
  Before the prompt is passed to the Gen-AI model, it may be formatted, truncated, expanded, or modified in other ways to meet that model’s requirements so the API call is successful.
</Note>

These preprocessing steps are integral to deliver an optimized prompt that generates coherent and relevant responses. By examining the prompt after preprocessing, you can better understand how your input is being interpreted by the AI, which can help you refine your queries for more accurate and useful outputs.

The input parameter keys and values are the same used in the [Prediction API `passthrough` use case](/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-prediction-api/passthrough-prediction) except for `apiKey` or similar authentication params, which must be provided for consistency. However, the model third-party API is *not* called, so those parameters are not used. You can enter placeholder values instead.

<Note>
  For detailed API specifications in Swagger/OpenAPI format, see [Platform APIs](/api-reference/passthrough-prompt/passthrough-prompt).
</Note>

<LwTemplate />

## Prerequisites

To use this API, you need:

* The unique `APPLICATION_ID` for your Lucidworks AI application, which is provided by Lucidworks.
* A bearer token generated with a scope value of `machinelearning.predict`. For more information, see [Authentication API](/docs/lw-platform/lw-platform/authentication-api).
* The Gen-AI model name in the `MODEL_ID` field for the request. The path is: `/ai/prompt/passthrough/MODEL_ID`. For more information about supported models, see [Generative AI models](/docs/lw-platform/lw-ai/lw-ai-generative-ai#generative-ai-models).

## Common parameters and fields

Some parameters in the `/ai/prompt/passthrough/MODEL_ID` request POST request are common to all of the generative AI (Gen-AI) use cases.
Also referred to as hyperparameters, these fields set certain controls on the response.
Refer to the [API spec](/api-reference/passthrough-prompt/passthrough-prompt) for more information.

### useCaseConfig parameters

The request also uses the following `useCaseConfig` parameters:

<ResponseField name="useCaseConfig" type="object">
  <Expandable title="useSystemPrompt (boolean)">
    <ResponseField name="useSystemPrompt" type="boolean">
      Enables or disables automatic system prompts.\
      If `true`, the LLM input is wrapped in a model-specific prompt format with a generic system prompt before sending to the model or third-party API.\
      If `false`, the `batch.text` value serves directly as the prompt. The input must meet the model’s requirements because it is passed as is.\
      Use this parameter if custom prompts are needed, or if the prompt response format must be manipulated. Longer prompts may increase response time.\
      Some models, such as `llama-3-8b-instruct`, generate more effective results when system prompts are included.
    </ResponseField>
  </Expandable>

  <Expandable title="dataType (string)">
    <ResponseField name="dataType" type="string">
      Optional parameter that controls how the text in the `/prompt` request is handled.\
      Accepted values:

      * `"text"`: Equivalent to `"useSystemPrompt": true`. Uses a pre-defined, generic system prompt.

      * `"raw_prompt"`: Equivalent to `"useSystemPrompt": false`. The request text is passed directly to the model.

      * `"json_prompt"`: Allows role-based formatting with the roles `system`, `user`, and `assistant`.\
        Additional rules for `json_prompt`:

      * Only the last `user` message is truncated. If the API does not support system prompts, the `user` role substitutes for the system role.

      * If the last message role is `assistant`, it is used as a pre-fill for generation. This reduces verbosity and can enforce specific outputs such as YAML. Google Vertex AI does not support pre-fills and raises an error.

      * Consecutive messages for the same role are merged.

      * You can paste the information for a hosted model into the `json_prompt` value and change the model name in the stage.

      * Follows HuggingFace chat template constraints. See [Hugging Face chat templates](https://huggingface.co/docs/transformers/main/en/chat_templating).
    </ResponseField>
  </Expandable>
</ResponseField>

<Note>
  If both `useSystemPrompt` and `dataType` are present, the value in `dataType` is used.
</Note>

## Example

The following example is a POST prompt request. Replace the values in the `APPLICATION_ID`, `MODEL_ID`, and `ACCESS_TOKEN` fields with your information.

<CodeGroup>
  ```json wrap Request theme={"dark"}
  curl --request POST \
    --url https://APPLICATION_ID.applications.lucidworks.com/ai/prompt/passthrough/{MODEL_ID} \
    --header 'Authorization: Bearer ACCESS_TOKEN' \
    --header 'Content-type: application/json' \
    --data '{
      "batch": [
          {
              "text": "[{\"role\": \"system\", \"content\": \"You are a helpful utility program instructed to accomplish a product classification task. Please, classify the provided product name into one of the following categories:\\nGROCERIES, FURNITURE, UNKNOWN\"}, {\"role\": \"user\", \"content\": \"chocolate milk\"}, {\"role\": \"assistant\", \"content\": \"GROCERIES\"}, {\"role\": \"user\", \"content\": \"chocolate table\"}, {\"role\": \"assistant\", \"content\": \"FURNITURE\"}, {\"role\": \"user\", \"content\": \"stone baked pizza\"}]"
          }
      ],
      "useCaseConfig": {
          "dataType": "json_prompt"
      },
      "modelConfig": {
          "apiKey": "fake"
      }
  }'
  ```

  ```json wrap Llama3 theme={"dark"}
  {
      "predictions": [
          {
              "tokensUsed": {
                  "promptTokens": 95
              },
              "prompt": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are a helpful utility program instructed to accomplish a product classififcation task. Please, classify the provided product name into one of the following categories:\nGROCERIES, FURNITURE, UNKNOWN<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nchocolate milk<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nGROCERIES<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nchocolate table<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\nFURNITURE<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nstone baked pizza<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"
          }
      ]
  }
  ```

  ```json wrap OpenAI theme={"dark"}
  [
      {
          "tokensUsed": {
              "promptTokens": 92
          },
          "messages": [
              {
                  "role": "system",
                  "content": "You are a helpful utility program instructed to accomplish a product classififcation task. Please, classify the provided product name into one of the following categories:\nGROCERIES, FURNITURE, UNKNOWN"
              },
              {
                  "role": "user",
                  "content": "chocolate milk"
              },
              {
                  "role": "assistant",
                  "content": "GROCERIES"
              },
              {
                  "role": "user",
                  "content": "chocolate table"
              },
              {
                  "role": "assistant",
                  "content": "FURNITURE"
              },
              {
                  "role": "user",
                  "content": "stone baked pizza"
              }
          ]
      }
  ]
  ```

  ```json wrap Anthropic theme={"dark"}
  [
      {
          "tokensUsed": {
              "promptTokens": 96
          },
          "messages": [
              {
                  "role": "system",
                  "content": "You are a helpful utility program instructed to accomplish a product classififcation task. Please, classify the provided product name into one of the following categories:\nGROCERIES, FURNITURE, UNKNOWN"
              },
              {
                  "role": "user",
                  "content": "chocolate milk"
              },
              {
                  "role": "assistant",
                  "content": "GROCERIES"
              },
              {
                  "role": "user",
                  "content": "chocolate table"
              },
              {
                  "role": "assistant",
                  "content": "FURNITURE"
              },
              {
                  "role": "user",
                  "content": "stone baked pizza"
              }
          ]
      }
  ]
  ```
</CodeGroup>
