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

# Make inference requests

> Get completions from models deployed on Adaptive Engine

You can run inference for a target use case (and optionally model) using the Adaptive Python SDK, or the OpenAI Python library.
The Adaptive SDK adopts a messages format similar to OpenAI’s Python library.

If you do not set a `model`, the Adaptive client routes your request to the model you've set as default for the client's use case,
or one of the models included in an active [A/B test](/v0.5/guides/abtesting).

Interactions (pairs of \[messages, completion] resulting from chat requests) are logged and saved to the Adaptive Interaction Store by default.

<Info>
  [Create](/v0.5/concepts/authentication) an `Adaptive` or `OpenAI` client first if applicable.
</Info>

<Tabs>
  <Tab title="Adaptive SDK">
    ```python theme={null}
    response = adaptive.chat.create(
      use_case="use_case_key",
      model="[optional_model_key]",
      messages=[
        {"role": "system", "content": "You are a good bot."},
        {"role": "user", "content": "Hello model!"}
      ],
      labels={"label_key": "label_value"}
    )
    ```

    See the [SDK Reference](https://adaptive-ml.github.io/adaptive-sdk-docs/adaptive_sdk/resources.html#Chat.create) for the full method definition.
  </Tab>

  <Tab title="Open AI Python">
    If you are using the Open AI Python library, `model` should be `use_case_key/[optional_model_key]`.

    ```python theme={null}
    response = oai_client.chat.completions.create(
      model="use_case_key/[optional_model_key]",
      messages=[
        {"role": "system", "content": "You are a good bot."},
        {"role": "user", "content": "Hello model!"}
      ],
      metadata={"label_key": "label_value"}
    )
    ```
  </Tab>

  <Tab title="requests">
    If you are using `requests`, `model` should be `use_case_key/[optional_model_key]`.

    ```python theme={null}
    import requests 

    headers = {"Authorization": "Bearer ADAPTIVE_API_KEY"}
    payload = { 
      "model": "use_case_key/[optional_model_key]",
      "messages": [
        {"role": "system", "content": "You are a good bot."},
        {"role": "user", "content": "Hello model!"}
      ],
      "labels": {"label_key": "label_value"}
    }


    response = requests.post(
      url="ADAPTIVE_URL/api/v1/chat/completions",
      json=payload,
      headers=headers
    )
    ```
  </Tab>

  <Tab title="curl">
    If you are using `curl`, `model` should be `use_case_key/[optional_model_key]`.

    ```bash curl theme={null}
    curl "$ADAPTIVE_URL/api/v1/chat/completions" \
      -X POST \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $ADAPTIVE_API_KEY" \
      -d '{
        "model":"use_case_key/[optional_model_key]",
        "messages":[{"role":"user","content":"Hello model!"}],
        "labels":{"label_key":"label_value"}
      }'
    ```
  </Tab>
</Tabs>

You can optionally tag requests with labels, as illustrated above.
Labels are useful to organize and categorize completions.
The `labels` parameter is a dictionary of user-defined key-value pairs, for example `labels = {"project": "RAG Bot", "topic": "Industrial Tools"}`.
If you are using the OpenAI Python library, `labels` is not a supported parameter, but you can pass your labels in `metadata`,
and they will be logged as any other label in Adaptive Engine.

Although the OpenAI Python library can be used to make inference requests to your Adaptive Engine deployment,
not all of Adaptive Engine’s input parameters are supported by OpenAI’s library and vice-versa.
See [Chat API Reference](/api-reference/completions/post-apiv1chatcompletions) for a list of supported parameters.

Both the Adaptive SDK’s and OpenAI Python library’s return types are Pydantic Models, which help with autocompletion within your editor.
You can access the model’s response text with:

<CodeGroup>
  ```python requests theme={null}
  completion_text = response.json()["choices"][0]["message"]["content"]
  ```

  ```python Adaptive SDK / OpenAI Python theme={null}
  completion_text = response.choices[0].message.content
  ```
</CodeGroup>
