Skip to main content

Quickstart

Connect a local /v1/chat/completions endpoint to an external testing platform through spectral-bridge.

Start a local endpoint

tip

If you already have a service exposing POST /v1/chat/completions, you can follow along with that instead. Just note its local endpoint (e.g., http://192.168.1.100:8000).

Install FastAPI:

Example
pip install "fastapi[standard]"

Save this echo bot as echo_bot.py. It mirrors the last user message back as the assistant reply, which is enough to validate the connection before switching to your real system.

Example
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
app = FastAPI()
@app.post("/v1/chat/completions")
async def chat(messages: list[dict]):
last = messages[-1]["content"]
return JSONResponse(
content={
"choices": [
{"message": {"role": "assistant", "content": last}}
]
}
)

Start it:

Example
fastapi run echo_bot.py --port 8000

The server listens on http://localhost:8000.

Connect to the testing platform

Install spectral-bridge

Example
pip install "spectral-bridge[pass-through]"

Set your API key

The testing platform provides an API key that authenticates the relay client with their relay server. Set it as an environment variable:

Example
export SPECTRAL_BRIDGE_API_KEY=<your-api-key>
tip

Using Spectral? This key is the api_key returned when you create an internal target. It is shown only once, so copy it from that response.

Connect to the relay

Point --target at your local endpoint:

Example
spectral-bridge start \
--adapter pass-through \
--target <local-target-url>

Replace <local-target-url> with the URL of your local endpoint (e.g., http://localhost:8000, http://192.168.1.100:8000).

tip

Connecting to another testing platform? Pass its relay server URL explicitly with --relay-url wss://relay.example.com/connect (or the SPECTRAL_BRIDGE_RELAY_URL environment variable).

Once the connection is established, leave it running as long as you want to allow the testing platform to send requests to your AI system through spectral-bridge. Once you terminate it, the connection is closed and the testing platform can no longer reach your system.

Next steps