> ## 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.

# Lucidworks AI APIs

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>;
};

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

[localhost link]: http://localhost:3000/docs/lw-platform/lw-ai/lw-ai-apis/overview

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

Lucidworks AI offers several APIs for managing and automating your AI implementation.
You can use them to [train and manage models](/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-models-api), run [synchronous](/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-prediction-api/overview) and [asynchronous predictions](/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-async-prediction-api/overview), preview and debug [pass-through prompts](/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-prompting-preview-api) and [embedding model tokens](/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-tokenization-api), and [chunk text](/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-async-chunking-api).
Lucidworks AI APIs let you control and customize your AI orchestration to suit your business needs by enabling developer teams to build out bespoke integrations and implementations.

You can use the Lucidworks AI APIs in addition to, or instead of, the Lucidworks Platform UI, but some actions are only supported with the APIs or through [Fusion pipeline stages](/docs/lw-platform/lw-ai/lw-ai-stages/overview).
For example, you can use the [custom model training user interface](/docs/lw-platform/lw-ai/lw-ai-custom-embedding-model-training/custom-model-training-user-interface) or the [Models API](/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-models-api) to train and deploy custom models, but running predictions and chunking text require you to use the APIs or Fusion stages.

Some APIs are used in conjunction with other APIs.
For example, use the [Use Case API](/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-use-case-api) and [Tokenization API](/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-tokenization-api) to generate values for the [Prediction API](/docs/lw-platform/lw-ai/lw-ai-apis/lw-ai-prediction-api/overview).

<LwTemplate />

## API access tokens

Lucidworks AI APIs require you to authenticate using [Java Web tokens (JWT) tokens](https://jwt.io/).
Generate these tokens using the [Authentication API](/docs/lw-platform/lw-platform/authentication-api), then include them in the request header.

<Accordion title="Fetch an access token" icon="key">
  <Steps>
    <Step title="Locate your integration">
      In the Platform UI, navigate to **Models** > **Integrations** and click on your integration.
      To fetch an access token, you'll need these details from your integration:

      * Client ID
      * Client secret

      [Learn more about integrations](/docs/lw-platform/lw-ai/integrations).
    </Step>

    <Step title="Compose your request">
      You'll send your access token request using the [Authentication API](/docs/lw-platform/lw-platform/authentication-api).

      The request uses basic authentication, where your base64-encoded client ID is your username and your base64-encoded client secret is your password.
      Some clients perform the encoding automatically; if not, you can use the `base64` command line utility, like this:

      ```bash theme={"dark"}
      echo -n "CLIENT_ID:CLIENT_SECRET" | base64
      ```

      Compose your request like this:

      ```bash theme={"dark"}
      curl --request POST \
        --url 'https://identity.lucidworks.com/oauth2/ausao8uveaPmyhv0v357/v1/token?scope=API_SCOPE&grant_type=client_credentials' \
        --header 'Accept: application/json' \
        --header 'Authorization: Basic [CLIENT_ID:CLIENT_SECRET_BASE64]' \
        --header 'Cache-Control: no-cache' \
        --header 'Content-Type: application/x-www-form-urlencoded'
      ```

      The value of the `scope` query parameter varies between APIs, and you need a separate access token for each scope:

      * The Models API uses the `machinelearning.model` scope.
      * All other APIs use the `machinelearning.predict` scope.
    </Step>

    <Step title="Fetch the access token">
      When you send a successful Authentication API request, the JSON response looks like this:

      ```json theme={"dark"}
      {
      "token_type": "Bearer",
      "expires_in": 3600,
      "access_token": "ACCESS_TOKEN",
      "scope": "API_SCOPE"
      }
      ```

      Copy the value of the `access_token` key and use it for API authentication.
    </Step>

    <Step title="Refresh your token every 60 minutes">
      API access tokens expire after 60 minutes.

      <Warning>
        Once you request a new token, the previous one is deleted *even if it has not yet expired*.
        All subsequent API calls must use the new token.
      </Warning>
    </Step>
  </Steps>
</Accordion>

## Using the APIs

Once you have an access token, you're ready to send API requests.

The base URL depends on the API:

| API                   | Base URL                                             |
| --------------------- | ---------------------------------------------------- |
| Authentication API    | `https://identity.lucidworks.com`                    |
| Async Chunking API    | `https://APPLICATION_ID.applications.lucidworks.com` |
| Async Prediction API  | `https://APPLICATION_ID.applications.lucidworks.com` |
| Models API            | `https://api.lucidworks.com`                         |
| Prediction API        | `https://APPLICATION_ID.applications.lucidworks.com` |
| Prompting Preview API | `https://APPLICATION_ID.applications.lucidworks.com` |
| Tokenization API      | `https://APPLICATION_ID.applications.lucidworks.com` |
| Use Case API          | `https://APPLICATION_ID.applications.lucidworks.com` |

You can get the `APPLICATION_ID` from your integration (at **Models** > **Integrations** in the Platform UI).

Your request must include a Bearer authorization header containing your access token, like this:

```
Authorization: Bearer ACCESS_TOKEN
```

See the [Platform API Reference](/api-reference/request-access-token/request-access-token) for details about all of the available endpoints.
The additional pages in this section also provide information to help you learn about each API.
