# API Key Not Working? Check Base URL, Model & Errors | Sidrune

Troubleshoot API connection failures by checking your Base URL, API format, key permissions, and model ID. Use a minimal request to diagnose 401, 404, and 429 errors.

Source: https://sidrune.ai/blog/api-key-connection-troubleshooting

> **TL;DR:** You have pasted your API key and clicked “Test connection,” but the tool returns a 401, a 404, or “model not found.” Start by checking four things: **the API format selected in the tool, the actual request URL, the key’s permissions, and the model ID**. Then send one short message to verify the configuration. Replacing the key alone will not fix an incorrect URL or a mismatched request format. [Sidrune docs](https://docs.global.sidrune.ai/user-guide/help-center)  [CloudAIKit docs](https://help.cloudaikit.com/zh-tw/guide/quick-start/core-params.html)

This guide starts with the configuration fields and helps you narrow down the failure. The goal is to get one text response with a consistent configuration, and know what to send support if it still fails.

## Check these four settings together

An API key is an access credential. It does not tell your tool which URL to connect to, which request format to use, or which model to call. [Sidrune docs](https://docs.global.sidrune.ai/user-guide/help-center)  [OpenAI SDK](https://github.com/openai/openai-python)

| Setting | What to check | What to do |
| --- | --- | --- |
| API format / provider type | Does the tool use Chat Completions, Responses, or Anthropic Messages? | Compare the tool’s instructions with the provider’s integration guide |
| Base URL | Does the field expect a root URL, a prefix including `/v1`, or a complete endpoint? | Inspect the final URL sent by the tool |
| API key | Is it issued by the same provider, still valid, and authorized for the target model? | Check the key’s status and group in the console |
| Model / model ID | Is this the complete API identifier supplied by the provider? | Copy it from the current model list instead of typing it manually |

Write down these four settings. Change one at a time, then retry the same short prompt so you can compare the results.

## Should the Base URL include `/v1`? Check how the tool builds the URL

“Always add `/v1`” is not a universal rule. Some fields accept an API prefix; some tools append the version and endpoint path themselves. What matters is **the complete URL that the tool actually sends**. [CloudAIKit docs](https://help.cloudaikit.com/zh-tw/guide/quick-start/core-params.html)

The following is an illustrative address, not a working API endpoint:

```text
Base URL:       https://api.example.com/v1
Tool appends:   /chat/completions
Final URL:      https://api.example.com/v1/chat/completions
```

If the tool already appends `/v1/chat/completions`, adding `/v1` to its prefix can duplicate the path. Similarly, entering a complete `/chat/completions` endpoint in a field that expects only a prefix can produce a repeated endpoint path. [CloudAIKit docs](https://help.cloudaikit.com/zh-tw/guide/quick-start/core-params.html)

When you see a 404, inspect the URL in the logs and compare it with the tool’s official example. Being able to open the provider’s homepage in a browser does not establish that your API endpoint is correct.

## Match the API format and model ID to the key’s access

Even when a provider supports an “OpenAI-compatible API,” you still need to identify the endpoint. Chat Completions and Responses are separate interfaces, and Anthropic Messages has its own request format. Changing the URL while keeping a request body intended for a different interface is not enough. [OpenAI SDK](https://github.com/openai/openai-python)  [OpenAI API docs](https://developers.openai.com/api/docs/)

For example, Sidrune’s global documentation uses `https://global.sidrune.ai/v1` for its OpenAI-compatible configuration and the root URL `https://global.sidrune.ai/` for its Anthropic-compatible configuration. It also instructs users to check API types and available models against the key’s group. These are configurations for the corresponding integration methods, not universal values for every tool’s URL field. [Sidrune docs](https://docs.global.sidrune.ai/user-guide/help-center)

Copy the API model ID from the current console. A product’s display name, a tool’s built-in selection, and the model ID available through a provider may be different strings. [Sidrune docs](https://docs.global.sidrune.ai/user-guide/help-center)

If the error explicitly says `model_not_found` or “unsupported model,” check the model ID and permissions next. If the response is an HTML error page, first check whether the request reached a website route or the wrong endpoint. Both can appear as a connection failure, but they call for different checks. [Sidrune docs](https://docs.global.sidrune.ai/user-guide/help-center)  [CloudAIKit docs](https://help.cloudaikit.com/zh-tw/guide/quick-start/core-params.html)

## Use a minimal request to separate tool configuration from API problems

Keep the same key, model, and API format, and send just one short message. Leave out images, attachments, tool calls, and long conversations for now. Verify the text request first, then add the features your actual task needs one at a time.

The example below is only for a text model **confirmed to support OpenAI Chat Completions**. It requires Python and the `openai` package. Set the environment variables in the environment that runs the script: `AI_BASE_URL` must contain the provider’s prefix for this SDK, and `AI_MODEL` must contain the complete ID of an available model. Do not put a real key in the source code or commit it to a repository. [OpenAI SDK](https://github.com/openai/openai-python)

```python
import os
from openai import OpenAI, APIStatusError, APIConnectionError

client = OpenAI(
    api_key=os.environ["AI_API_KEY"],
    base_url=os.environ["AI_BASE_URL"],
    max_retries=0,
    timeout=30.0,
)

try:
    result = client.chat.completions.create(
        model=os.environ["AI_MODEL"],
        messages=[{"role": "user", "content": "Reply only: Connection successful"}],
        stream=False,
    )
    print(result.choices[0].message.content)
except APIStatusError as error:
    print("HTTP status:", error.status_code)
    print("Request ID:", error.request_id)
    print("Error details:", error.response.text)
except APIConnectionError:
    print("No usable HTTP response. Check the network, proxy, and connection settings.")
```

This troubleshooting example follows the SDK documentation. If your provider requires additional parameters, add them according to its instructions. Check the selected model’s billing before running the test: test requests can generate usage. Inspect error details locally and redact credentials and private information before sharing them. [Sidrune docs](https://docs.global.sidrune.ai/user-guide/help-center)  [OpenAI SDK](https://github.com/openai/openai-python)

Interpret the results as follows:

- **The example returns a response, but your original tool fails:** first compare the configuration actually loaded by the tool, its endpoint, request body, and proxy environment. Do not immediately assume the key is invalid.
- **Both return the same error:** use the error details to check permissions, the model, or account status before deciding what to change.
- **The example times out without an HTTP status:** check the network and connection layer first. A timeout alone does not establish that the model name is wrong.

One successful short message verifies that particular request. You still need to test the features you actually need in the original tool, such as streaming or attachment handling.

## What should you check after a 401, 403, 404, or 429?

An HTTP status is a starting point. Read the response’s `message`, `type`, or `code` as well. Providers may classify failures differently, so a number alone is not a complete diagnosis. [CloudAIKit docs](https://help.cloudaikit.com/zh-tw/guide/quick-start/core-params.html)  [OpenAI error codes](https://developers.openai.com/api/docs/guides/error-codes)

| Symptom | Check first | Next step |
| --- | --- | --- |
| 401 / authentication failure | Key, authentication headers, stale configuration | Verify the authentication method actually sent and the key’s status |
| 403 / access denied | The permission or access restriction specified in the response | Check the relevant model, account, or network access requirements |
| 404 / model or endpoint not found | Complete URL and model ID | Distinguish a path error from a model error |
| 429 / request restricted | The specific rate, quota, or spending-limit error | Wait as instructed for rate limits; resolve account limits first for quota errors |
| 5xx / server error | Service status and request ID | Record the error, then retry within limits or contact support according to the provider’s guidance |

In particular, do not retry continuously after a 429. OpenAI’s error documentation distinguishes request-rate limits from credit and spending limits. Waiting will not resolve every account restriction. This illustrates why you need to read the error details; it does not mean every provider uses OpenAI’s exact classifications. [OpenAI error codes](https://developers.openai.com/api/docs/guides/error-codes)

If your integration already works and you encounter Claude Code usage limits during continued use, see the [usage-limit guide](https://sidrune.ai/blog/claude-code-usage-limit). Distinguishing “the first request has never worked” from “it worked before and is now restricted” keeps your investigation focused.

## What counts as a working integration?

Use three checks: the tool you intend to use returns a valid text response, it uses your intended provider and model configuration, and you can match the request against the usage records available from the provider. Do not stop just because a connection-test button turns green.

Sidrune provides API key and usage-record access. Follow the [global integration documentation](https://docs.global.sidrune.ai/user-guide/help-center) to verify your configuration, then inspect the request and its usage. If you are ready to get started, [register for Sidrune Global](https://global.sidrune.ai/register?aff=7T2JFVEH79XA), confirm the applicable group and model, and complete one small task first. [Sidrune docs](https://docs.global.sidrune.ai/user-guide/help-center)

If it still fails, give support enough information to reproduce it: the tool and version, operating system, API format, complete endpoint path, model ID, time and time zone, HTTP status, request ID, and the original error with sensitive information redacted. Do not include the full API key. [OpenAI SDK](https://github.com/openai/openai-python)

You have reached a useful stopping point when you can identify the configuration that completed the request, or the specific error still blocking it. When you switch tools, use that configuration as your reference.
