PROMO$5 FREE CREDITS

    Point the OpenAI Python SDK at Refuseless

    All guides

    You switch the OpenAI Python SDK to Refuseless by passing base_url="https://api.refuseless.com/v1" when you construct the client, and by sending a Refuseless model id. The rest of chat.completions.create stays the shape you already have. The key is a Refuseless API key from the console, not an OpenAI key. The SDK will happily send an OpenAI key to the wrong host, and you will get a 401.

    Install and call

    Install the official SDK (pip install openai) if the project does not have it. Export REFUSELESS_API_KEY. Then construct the client with the base URL. The sample uses glm-5.3-refuseless, the id used for GLM 5.3 Abliterated in this codebase. If the models page lists a different id for that checkpoint, copy that id. GET /v1/models returns the ids the key can call.

    Python
    from openai import OpenAI
    import os
    
    client = OpenAI(
        api_key=os.environ["REFUSELESS_API_KEY"],
        base_url="https://api.refuseless.com/v1",
    )
    
    response = client.chat.completions.create(
        model="glm-5.3-refuseless",
        messages=[
            {"role": "user", "content": "Summarize this function in one paragraph."},
        ],
    )
    print(response.choices[0].message.content)

    What you do not change

    • Message roles. system, user, and assistant mean what they mean in the OpenAI shape.
    • The path. The SDK appends /chat/completions to the base URL. Do not also append /v1 in the base URL and in the path.
    • Streaming, if you already pass stream=True. Leave it. This page does not add a second client.

    Errors you will actually see

    • HTTP 401, "Missing bearer API key." The Authorization header never arrived. Check that the environment variable is set in the process that imports the SDK.
    • HTTP 401, "Invalid API key." The header arrived and the key is not one of ours. An OpenAI key will do this.
    • HTTP 404, code model_not_found, message "Unknown model." The id is not in the catalog. Copy one from GET /v1/models or the models page.
    • HTTP 404 on a path you invented. The error body lists the supported methods: chat completions, responses, completions, embeddings where the model offers them, and GET /v1/models.

    The Node SDK is the same idea with baseURL in camelCase. That page is here. Pricing stays on the pricing page, because a snippet that hardcodes a rate goes stale on purpose.

    Get an API keySee the lineup