Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) · Versioning:
the ambient `OPENAI_API_BASE` auto-registration path, and no-op API-key
prefix inference. Custom gateways and endpoints now require explicit,
instance-local configuration.
- **Renamed host product references to decoder.** Host config paths (`~/.decoder/`),
- **Frozen legacy identifiers.** For compatibility, host config paths (`~/.decoder/`),
the `decoder_build`/`decoder_build_concise` tool namespaces, the `decoder_response`
schema name, and the `EXPORT_DECODER_FIXTURE` env var now use the decoder identity.
References to retired ecosystem repos were removed.
schema name, and the `EXPORT_DECODER_FIXTURE` env var retain the decoder identity;
the product is now Relay. References to retired ecosystem repos were removed.
- **Credential env-file migration falls back to the pre-rename host config
directory** so installs created before the rename still migrate.

Expand Down
15 changes: 7 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ for the full list. The most common targets:

| Target | What it does |
| ------------------- | ------------------------------------------------ |
| `make build` | Build the binary / verify the library compiles |
| `make build` | Compile all library packages |
| `make test` | Run unit tests |
| `make test-race` | Run unit tests with the race detector |
| `make cover` | Generate a coverage report |
| `make lint` | Run the linter (`golangci-lint` / `ruff`) |
| `make lint` | Run `golangci-lint` |
| `make fmt` | Format source files |
| `make vet` | Run `go vet` / `mypy` |
| `make security` | Run `govulncheck` / `pip-audit` |
| `make vet` | Run `go vet` |
| `make security` | Run `govulncheck` |
| `make ci` | Run everything CI runs (the gate before pushing) |

## Commit message convention
Expand Down Expand Up @@ -118,10 +118,9 @@ Before requesting review:

## Reporting bugs

Open an issue using the bug-report template. Include the `relay`
version (`relay --version` for binaries, `relay.Version` for
libraries — see this repo's `VERSION` file), reproduction steps, expected
behaviour, and actual behaviour.
Open an issue using the bug-report template. Include the Relay version
(`relay.Version`, or this repo's `VERSION` file), reproduction steps,
expected behaviour, and actual behaviour.

## Reporting security issues

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Canonical graycode-eco Makefile for Go LIBRARY repos.
# relay is a versioned Go library consumed by Decoder (no standalone binary).
# relay is a versioned Go library consumed by Reflect (no standalone binary).

# ---------------------------------------------------------------------------
# Project metadata
Expand All @@ -8,7 +8,7 @@ NAME := relay

# ---------------------------------------------------------------------------
# Versioning — sourced only from VERSION.
# See https://github.com/GrayCodeAI/decoder/blob/main/docs/versioning.md.
# See https://github.com/GrayCodeAI/reflect/blob/main/docs/versioning.md.
# ---------------------------------------------------------------------------
VERSION := $(shell tr -d '[:space:]' < VERSION)
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
Expand Down Expand Up @@ -49,7 +49,7 @@ all: lint test build ## Default — lint, test, build.
# ---------------------------------------------------------------------------
# Build / install / release.
# ---------------------------------------------------------------------------
build: version-sync ## Build all library packages (relay is a library consumed by decoder; no standalone binary).
build: version-sync ## Build all library packages (relay is a library consumed by Reflect; no standalone binary).
go build ./...

# ---------------------------------------------------------------------------
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ resp, err := c.Chat(ctx, messages, llm.ChatOptions{

```go
// Auto-continues when max_tokens is hit
resp, err := provider.ChatWithContinuation(ctx, provider, messages,
resp, err := resilience.ChatWithContinuation(ctx, p, messages,
llm.ChatOptions{Model: model},
core.DefaultContinuationConfig(),
)
Expand All @@ -271,7 +271,7 @@ resp, err := provider.ChatWithContinuation(ctx, provider, messages,
### Mock Provider for Testing

```go
mock := provider.NewMockProvider(provider.MockModeFixed)
mock := testkit.NewMockProvider(testkit.MockModeFixed)
mock.Response = "Here is the code you asked for..."

resp, _ := mock.Chat(ctx, messages, opts)
Expand All @@ -281,11 +281,10 @@ resp, _ := mock.Chat(ctx, messages, opts)
### Model Catalog

```go
cat := catalog.DefaultModelCatalog()
cat := catalog.SeedModelCatalog()

// Get the best model for a tier
model := catalog.GetPreferredProviderModel("anthropic", catalog.TierSonnet, &cat)
// → "claude-sonnet-4-6"

// Check deprecation warnings
warn := catalog.GetModelDeprecationWarning("claude-3-7-sonnet", "anthropic")
Expand Down Expand Up @@ -396,7 +395,7 @@ Quick start:
3. Run `make ci` locally
4. Open a pull request

Use [Conventional Commits](https://www.conventionalcommits.org/) for commit messages — release-please uses them for versioning.
Use [Conventional Commits](https://www.conventionalcommits.org/) for commit messages — they drive the release notes and the hand-written CHANGELOG.

## License

Expand Down
13 changes: 6 additions & 7 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ We follow [coordinated vulnerability disclosure](https://en.wikipedia.org/wiki/C

- **Dependency monitoring:** vulnerable dependencies are detected by
`govulncheck`, which runs on every CI build (see "Vulnerability scanning").
- **Static analysis:** `golangci-lint` / `ruff` / `mypy` enforced in CI.
- **Vulnerability scanning:** `govulncheck` (Go) / `pip-audit` (Python) run
on every CI build.
- **Lockfiles:** `go.sum` / `pnpm-lock.yaml` / `pyproject.toml` are pinned
and committed.
- **Reproducible builds:** release artefacts ship with SHA-256 checksums via
goreleaser.
- **Static analysis:** `golangci-lint` is enforced in CI.
- **Vulnerability scanning:** `govulncheck` runs on every CI build.
- **Lockfiles:** `go.sum` is pinned and committed.
- **Release integrity:** releases are cut from signed `v*` tags by
`.github/workflows/release.yml` after `scripts/sync-version.py --check`
verifies the tag matches `VERSION`.
- **No secrets in source:** API keys are configuration, not constants. Pre-
commit hooks block accidental secret commits.

Expand Down
2 changes: 1 addition & 1 deletion assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion catalog/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package catalog

// Credentials carries API keys and related env (base URLs) for provider-backed catalog discovery.
// Keys use standard env var names (e.g. OPENROUTER_API_KEY). Populate via config.DiscoveryCredentials.
// or pass an explicit map from decoder — do not hardcode provider lists in decoder.
// or pass an explicit map from the host — do not hardcode provider lists in a host.
type Credentials struct {
APIKeys map[string]string
}
Expand Down
2 changes: 1 addition & 1 deletion catalog/provider_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func apiKeyEnvFromDeployment(dep Deployment) string {
}

// CredentialStatusForProvider reports whether a provider needs an API key (local vs required).
// For set/empty status use decoder config.EnvKeyStatus or credentials.HasSecret — catalog does not read env.
// For set/empty status use the host config.EnvKeyStatus or credentials.HasSecret — catalog does not read env.
func CredentialStatusForProvider(compiled *CompiledCatalog, providerID string) string {
providerID = canonicalProviderID(providerID)
if providerID == "" {
Expand Down
2 changes: 1 addition & 1 deletion config/discovery_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// DiscoveryCredentials loads API keys from the OS secret store (not process env or .env files),
// merged with non-secret routing from ~/.decoder/provider.json (e.g. MiMo Token Plan region/base URL).
// merged with non-secret routing from the relay provider.json in the user config directory (e.g. MiMo Token Plan region/base URL).
func DiscoveryCredentials(ctx context.Context) catalog.Credentials {
if ctx == nil {
ctx = context.Background()
Expand Down
8 changes: 4 additions & 4 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@

## <img src="https://cdn.jsdelivr.net/gh/lucide-icons/lucide@latest/icons/target.svg" width="16" height="16" alt="target" /> Overview

relay is the LLM provider runtime for the decoder ecosystem. It sits between the application and LLM APIs, handling **authentication**, **model resolution**, **streaming**, **retries**, **rate limiting**, and **caching**.
relay is the LLM provider runtime for the Reflect ecosystem. It sits between the application and LLM APIs, handling **authentication**, **model resolution**, **streaming**, **retries**, **rate limiting**, and **caching**.

> <img src="https://cdn.jsdelivr.net/gh/lucide-icons/lucide@latest/icons/lightbulb.svg" width="16" height="16" alt="lightbulb" /> No decoder ecosystem component talks to an LLM API directly — all communication goes through relay.
> <img src="https://cdn.jsdelivr.net/gh/lucide-icons/lucide@latest/icons/lightbulb.svg" width="16" height="16" alt="lightbulb" /> No Reflect ecosystem component talks to an LLM API directly — all communication goes through relay.

---

## <img src="https://cdn.jsdelivr.net/gh/lucide-icons/lucide@latest/icons/blocks.svg" width="16" height="16" alt="blocks" /> Components

```
relay/
├── engine/ Stable host-facing facade (decoder imports only this + llm/graph/tools)
├── engine/ Stable host-facing facade (Reflect imports only this + llm/graph/tools)
├── llm/ Host-facing DTOs + Provider port (engine re-exports)
├── graph/ Portable execution-graph vocabulary
├── tools/ Tool-call/result contracts
Expand Down Expand Up @@ -51,7 +51,7 @@ The current distributed-routing foundation and its limits are described in
## <img src="https://cdn.jsdelivr.net/gh/lucide-icons/lucide@latest/icons/globe.svg" width="16" height="16" alt="globe" /> API

relay is a Go library: it ships no binary, no `cmd/`, and no `relay serve`
command. Hosts such as decoder call the [`engine`](../engine/) facade in-process.
command. Hosts such as Reflect call the [`engine`](../engine/) facade in-process.

`internal/api` contains an HTTP server (`api.NewServer(api.Config{...})`, then
`ListenAndServe(addr)`) whose contract is [`api/openapi.yaml`](../api/openapi.yaml).
Expand Down
29 changes: 14 additions & 15 deletions docs/design/RELAY-ENTERPRISE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,20 @@ no telemetry exfiltration by default).

### Which Top-20 repos ship these features

From `TOP20_COMPARISON.md` (the relay section, lines 89–124):

| Capability | Top-20 repos that ship it | Comparison-doc reference |
|---|---|---|
| Multi-tenant team/project management with SSO/RBAC | LiteLLM, Portkey | `TOP20_COMPARISON.md:96` (P0) |
| Virtual-key budgets + admin dashboard UI | LiteLLM (per-key spend, hard limits, admin dashboard), Portkey | `TOP20_COMPARISON.md:96` |
| Helicone-style analytics dashboard (HQL, sessions, 21+ metrics) | Helicone, Portkey, LangSmith | `TOP20_COMPARISON.md:111` (P1) |
| Versioned prompt library + side-by-side model comparison | Portkey, LangSmith | `TOP20_COMPARISON.md:110` (P1) |
| Canary / blue-green model testing | Portkey (canary routing), LiteLLM | `TOP20_COMPARISON.md:107` (P1) |
| A2A (Agent-to-Agent) protocol | LiteLLM proxy (LangGraph, Vertex Agent Engine, Azure AI Foundry, Bedrock AgentCore) | `TOP20_COMPARISON.md:108` (P1) |
| Fine-tuning workflow integration | OpenAI, Vertex AI, Together AI | `TOP20_COMPARISON.md:123` (P2) |
| Priority queue with SLA tiers | LiteLLM, enterprise LLM gateways | `TOP20_COMPARISON.md:124` (P2) |

Relay's gap summary in the comparison doc: **2 P0 / 13 P1 / 5 P2** (`TOP20_COMPARISON.md:271`).
The enterprise gateway is the single largest cluster of those gaps and the one with no
Capability comparison against the top LLM gateway and observability projects:

| Capability | Projects that ship it |
|---|---|
| Multi-tenant team/project management with SSO/RBAC | LiteLLM, Portkey |
| Virtual-key budgets + admin dashboard UI | LiteLLM (per-key spend, hard limits, admin dashboard), Portkey |
| Helicone-style analytics dashboard (HQL, sessions, 21+ metrics) | Helicone, Portkey, LangSmith |
| Versioned prompt library + side-by-side model comparison | Portkey, LangSmith |
| Canary / blue-green model testing | Portkey (canary routing), LiteLLM |
| A2A (Agent-to-Agent) protocol | LiteLLM proxy (LangGraph, Vertex Agent Engine, Azure AI Foundry, Bedrock AgentCore) |
| Fine-tuning workflow integration | OpenAI, Vertex AI, Together AI |
| Priority queue with SLA tiers | LiteLLM, enterprise LLM gateways |

The enterprise gateway is the largest cluster of those gaps and the one with no
incremental code-session path — it requires a persistent org data model and a UI, which is why
it is treated here as a multi-month effort.

Expand Down
30 changes: 22 additions & 8 deletions docs/guides/CREDENTIAL-SETUP-FLOW.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

See also: [DYNAMIC-MODEL-DISCOVERY.md](./DYNAMIC-MODEL-DISCOVERY.md)

## Supported providers (15 — from `catalog/registry`)
## Supported providers (29 — from `catalog/registry`)

| Provider | ID | Credential | Picker models |
|----------|-----|------------|---------------|
Expand All @@ -14,10 +14,24 @@ See also: [DYNAMIC-MODEL-DISCOVERY.md](./DYNAMIC-MODEL-DISCOVERY.md)
| DeepSeek | `deepseek` | `DEEPSEEK_API_KEY` | live `/models` only |
| OpenRouter | `openrouter` | `OPENROUTER_API_KEY` | live `/models` only |
| xAI (Grok) | `grok` | `XAI_API_KEY` | live `/v1/models` only |
| Z.AI | `z-ai` | `ZAI_API_KEY` | live `/models` only |
| Z.AI — Coding Plan | `zai_coding` | `ZAI_CODING_API_KEY` | live `/models` only |
| Z.AI — Pay-as-you-go | `zai_payg` | `ZAI_API_KEY` | live `/models` only |
| CanopyWave | `canopywave` | `CANOPYWAVE_API_KEY` | live `/models` only |
| OpenCode Go | `opencodego` | `OPENCODEGO_API_KEY` | live `/models` only |
| Kimi (Moonshot) | `kimi` | `MOONSHOT_API_KEY` | live `/models` only |
| Azure OpenAI | `azure` | `AZURE_OPENAI_API_KEY` | live deployments |
| Amazon Bedrock | `bedrock` | `AWS_SECRET_ACCESS_KEY` (+ `AWS_ACCESS_KEY_ID`, region) | live model list |
| Vertex AI | `vertex` | `VERTEX_ACCESS_TOKEN` (+ project/region) | live model list |
| Concentrate AI | `concentrate` | `CONCENTRATE_API_KEY` | live model list |
| OpenGateway | `opengateway` | `OPENGATEWAY_API_KEY` | live model list |
| StepFun | `stepfun` | `STEP_API_KEY` | live model list |
| Agnes AI | `agnes` | `AGNES_API_KEY` | live model list |
| LongCat | `longcat` | `LONGCAT_API_KEY` | live model list |
| Fireworks AI | `fireworks` | `FIREWORKS_API_KEY` | live model list |
| Reflection AI | `reflection` | `REFLECTION_API_KEY` | live model list |
| Poolside | `poolside` | `POOLSIDE_API_KEY` | live model list |
| Groq | `groq` | `GROQ_API_KEY` | live model list |
| ClinePass | `clinepass` | `CLINE_API_KEY` | live model list |
| Xiaomi (MiMo) Pay-as-you-go | `xiaomi_mimo_payg` | `XIAOMI_MIMO_PAYG_API_KEY` | `https://api.xiaomimimo.com/v1` (`sk-` keys) |
| Xiaomi (MiMo) Token Plan | `xiaomi_mimo_token_plan` | `XIAOMI_MIMO_TOKEN_PLAN_API_KEY` | region: `cn` / `sgp` / `ams` (`tp-` keys) |
| MiniMax (minimax) Token Plan | `minimax_token_plan` | `MINIMAX_TOKEN_PLAN_API_KEY` | `https://api.minimax.io/v1` |
Expand Down Expand Up @@ -50,7 +64,7 @@ Relay stores Anthropic **base** as `…/anthropic` (no `/v1`); `AnthropicClient`

**Legacy:** `xiaomi_mimo` / `XIAOMI_MIMO_API_KEY` / keychain account `xiaomi_mimo_api_key` migrate to pay-as-you-go (`XIAOMI_MIMO_PAYG_API_KEY` / `xiaomi_mimo_payg_api_key`) on load and startup.

**Code:** `relay/catalog/xiaomi/` (URLs), `relay/provider/mimo.go` (dual-protocol client), `reflect/cmd/chat_config_region.go` (region UI).
**Code:** `relay/catalog/xiaomi/` (URLs), `relay/provider/adapters/mimo.go` (dual-protocol client), `reflect/cmd/chat_config_region.go` (region UI).

**Not implemented (out of scope):** ASR/TTS ([Speech Recognition](https://platform.xiaomimimo.com/docs/en-US/api/audio/Speech-Recognition), speech synthesis guides), web-search billing plugins, user toggle for Anthropic-primary routing.

Expand All @@ -71,11 +85,11 @@ Setup is **gateway-first**: pick the gateway on the Gateways tab, paste any non-

## Host API (reflect integrates through `relay/engine`)

- `ResolveCredentialForHost` / `SaveCredentialForHost`
- `ApplyRelayCredentials`
- `ListModelsForProvider` — registry-driven live vs cache
- `LocalCredentialInference("ollama")`
- `FormatSetupError(provider, err)`
- `(*engine.Engine).ResolveCredential` / `SaveCredential`
- `(*engine.Engine).ApplyCredentials`
- `(*engine.Engine).ListModels` / `ListLiveModels` — registry-driven live vs cache
- `config.LocalCredentialInference("ollama")`
- `engine.FormatSetupError(provider, err)`

## Adding a new provider

Expand Down
2 changes: 1 addition & 1 deletion setup/apply_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func ApplyCredentialsForProvider(ctx context.Context, providerID string, creds c
}

// ApplyCredentials discovers the model catalog from env API keys, then writes
// ~/.decoder/adapters.json deployments and routing derived from the catalog.
// relay provider.json deployments and routing derived from the catalog.
func ApplyCredentials(ctx context.Context, creds catalog.Credentials) (*ApplyCredentialsResult, error) {
catResult, err := DiscoverModelCatalog(ctx, creds)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion setup/setup_ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type ProviderUI struct {
Models []ModelUI `json:"models"`
}

// SetupUI is JSON-safe metadata returned to decoder (no secrets).
// SetupUI is JSON-safe metadata returned to the host (no secrets).
type SetupUI struct {
Providers []ProviderUI `json:"providers"`
}
Expand Down
2 changes: 1 addition & 1 deletion setup/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func FormatStatus(report StatusReport) string {
fmt.Fprintf(&b, " cached: no (using embedded catalog: %d models)\n", report.CatalogModels)
}
if report.CatalogStale {
b.WriteString(" stale: yes — decoder refreshes automatically; use `reflect models refresh` or `/refresh-model-catalog` for a manual run\n")
b.WriteString(" stale: yes — Reflect refreshes automatically; use `reflect models refresh` or `/refresh-model-catalog` for a manual run\n")
}
if report.ActiveModel != "" {
fmt.Fprintf(&b, "Active canonical model: %s\n", report.ActiveModel)
Expand Down
Loading