> For the complete documentation index, see [llms.txt](https://seekspeed.gitbook.io/seekspeed-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://seekspeed.gitbook.io/seekspeed-docs/connectors/testing.md).

# Connection Testing

Every connector form has a **Test** button that fires a 1-token completion before save. The result UI shows three things:

* HTTP status
* Wall-clock latency in ms
* The raw response body (truncated to 240 chars)

This catches the four most common config errors immediately:

1. Wrong base URL (`404` or `Connection refused`).
2. Missing or wrong API key (`401`).
3. Model name not deployed on this endpoint (`400 model not found`).
4. Azure `api-version` header missing or stale (`400 invalid api version`).

The server function never writes the test result anywhere — it returns it transiently to the UI. If you save and re-test later, results are not historical.

```ts
// src/lib/connector-test.functions.ts (real shape)
export const testConnector = createServerFn({ method: "POST" })
  .inputValidator((d) => Schema.parse(d))
  .handler(async ({ data }) => {
    const t0 = Date.now();
    try {
      const res = await fetch(`${data.baseUrl.replace(/\/+$/,"")}/chat/completions`, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          ...(data.apiKey ? { Authorization: `Bearer ${data.apiKey}` } : {}),
          ...data.headers,
        },
        body: JSON.stringify({
          model: data.model,
          messages: [{ role: "user", content: "ping" }],
          max_tokens: 1,
          temperature: 0,
        }),
      });
      const body = (await res.text()).slice(0, 240);
      return { ok: res.ok, status: res.status, ms: Date.now() - t0, body };
    } catch (e) {
      return { ok: false, status: 0, ms: Date.now() - t0, body: String(e) };
    }
  });
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://seekspeed.gitbook.io/seekspeed-docs/connectors/testing.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
