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

# Quickstart example

> Learn how to get started with Adaptive Engine

This quickstart example will teach you how to get started with Adaptive Engine, by mocking an AI customer support co-pilot use case.
You'll be taken through the following steps to deploy, use, and adapt your first model:

1. Install the Adaptive Python SDK
2. Create a new use case
3. Deploy a model and make an inference request
4. Log feedback on the model's completion
5. Adapt a model on previous interaction feedback

## Step-by-step walkthrough

<Steps>
  <Step title="Install the Adaptive Python SDK">
    First, you `pip install` the Adaptive SDK.

    ```bash theme={null}
    pip install adaptive_sdk
    ```

    Instantiate the `Adaptive` client.

    ```python Adaptive SDK theme={null}
    from adaptive_sdk import Adaptive

    adaptive = Adaptive(
        base_url="ADAPTIVE_URL",
        api_key="ADAPTIVE_API_KEY"
    )
    ```
  </Step>

  <Step title="Create a new use case">
    An Adaptive Engine [use case](/v0.5/concepts/use-cases) is a user-defined workspace where you group together resources such as models, interaction logs
    and metrics for monitoring and evaluation.

    You first create a `Customer Support Assistant` use case that to service your customer support operations.

    ```python Adaptive SDK theme={null}
    use_case = adaptive.use_cases.create(
        key="customer_support_assistant"
    )
    ```
  </Step>

  <Step title="Deploy a model and make an inference request">
    You deploy the Llama 3.1 70B instruction-tuned model and attach it to the use case, so your customer support agents can start using it.
    This is a capable base model that can provide satisfactory performance initially.
    Learn more about other supported [models](/v0.5/concepts/models).

    ```python Adaptive SDK theme={null}
    # configure default client use case
    # SDK methods will target the customer support use case going forward, unless specifically overridden
    client = adaptive.set_default_use_case(use_case.key)

    model = adaptive.models.attach(
        model="llama-3.3-70b-instruct",
    )
    ```

    You can now integrate the Adaptive SDK in your customer support application, and start making inference requests.
    The Adaptive Chat API is also [compatible](/v0.5/guides/inference) with the OpenAI Python library, so there is no need to refactor
    application code if you were previously using it.

    ```python Adaptive SDK theme={null}
    chat_response = adaptive.chat.create(
        model=model.key,
        messages=[
            {
                "role": "system",
                "content": "You are a helpful customer support assistant."
            },
            {
                "role": "user",
                "content": "I was blocked out of my account, I don't know why."
            }
        ]
    )
    print(chat_response.choices[0].message.content)
    ```

    Output:

    ```bash theme={null}
    Have you tried recovering your password?
    ```

    Pairs of `messages, completion` resulting from chat requests are automatically logged and saved on Adaptive.
  </Step>

  <Step title="Log feedback on the model's completion">
    Your customer support agent who is using the model as an assistant finds the model's completion appropriate, and accepts it to be sent to the customer.

    To log and aggregate this feedback, you register a new `Acceptance` feedback key, link it to your use case, and log the agent's feedback against the `completion_id`.

    ```python Adaptive SDK theme={null}
    feedback_key = adaptive.feedback.register_key(
        key="acceptance",
        kind="bool",
        scoring_type="higher_is_better",
    )
    _ = adaptive.feedback.link(feedback_key.key)

    completion_id = chat_response.choices[0].completion_id

    feedback = adaptive.feedback.log_metric(
        completion_id=completion_id,
        feedback_key=feedback_key.key,
        value=True,
    )
    ```

    Learn more about [feedback types](/v0.5/concepts/feedback) and [logging](/v0.5/guides/feedback) in Adaptive.
  </Step>

  <Step title="Adapt a model on previous interaction feedback">
    After running your customer support operations with the help of Adaptive Engine, you have accumulated feedback from your human agents in production.
    To align a model to the preferences of your human agents, you <span style={{color: '#7754BB', fontWeight: 'bold'}}>adapt</span> a smaller 8B model on the feedback you logged.
    This tunes the smaller model using reinforcement learning methods, learning from the successes and failures of the larger, more capable model.

    ```python Adaptive SDK theme={null}
    job = adaptive.training.jobs.create(
        model="llama-3.1-8b-instruct",
        data_source="COMPLETIONS",
        data_config={"selection_type": "ALL"},
        alignment_objective={
            "metric": {
                "metric_key": feedback_key.key
            }
        }
    )
    ```

    The job trains and saves a new, improved model that you can immediately deploy for better results!
    Learn more in [Adapt a model](/v0.5/fine-tuning/adapt).
  </Step>
</Steps>

## Next steps

* Check out how to [A/B test](/v0.5/guides/abtesting) models in production for easy iteration and decision making.
* Dive deeper into [training](/v0.5/fine-tuning/adapt) with Adaptive Engine.
