[Python] Copilot's API in a Python script gives 401

Discussão em 'Python' iniciado por Stack, Junho 21, 2025.

  1. Stack

    Stack Membro Participativo

    I use this api: https://pypi.org/project/copilot-api/

    Also just testing the default example code:

    from copilot_api import Copilot

    # Initialize Copilot
    copilot = Copilot()

    # Basic chat example
    messages = [
    {"role": "system", "content": "You are a helpful AI assistant."},
    {"role": "user", "content": "Hello!"}
    ]

    # Stream responses
    for response in copilot.create_completion(
    model="Copilot",
    messages=messages,
    stream=True
    ):
    if isinstance(response, str):
    print(response, end='', flush=True)


    When I run this, it gives me a 401 unauthorised. What am I missing here?

    Continue reading...

Compartilhe esta Página