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

# Build your first chatbot

> A complete, minimal chatbot on Askr.

This guide builds a working command-line chatbot that remembers the
conversation, in about 30 lines.

<Steps>
  <Step title="Install the SDK">
    ```bash theme={null}
    pip install openai
    ```
  </Step>

  <Step title="Write the loop">
    ```python theme={null}
    from openai import OpenAI

    client = OpenAI(base_url="https://api.heyaskr.ai", api_key="ASKR_API_KEY")
    messages = [{"role": "system", "content": "You are a friendly assistant."}]

    while True:
        user = input("You: ")
        if user.lower() in {"quit", "exit"}:
            break
        messages.append({"role": "user", "content": user})

        stream = client.chat.completions.create(
            model="gpt-5.5", messages=messages, stream=True
        )
        print("Askr: ", end="", flush=True)
        reply = ""
        for chunk in stream:
            token = chunk.choices[0].delta.content or ""
            print(token, end="", flush=True)
            reply += token
        print()
        messages.append({"role": "assistant", "content": reply})
    ```
  </Step>

  <Step title="Run it">
    ```bash theme={null}
    python chatbot.py
    ```

    Type to chat; type `quit` to exit. Switch `model` to try Claude, Gemini or
    any other model.
  </Step>
</Steps>
