Skip to content

feat(providers): add TARS (Tetrate Agent Router Service) as a built-in inference provider - #2535

Open
zhaohuabing wants to merge 2 commits into
NVIDIA:mainfrom
zhaohuabing:feat/tars-provider
Open

feat(providers): add TARS (Tetrate Agent Router Service) as a built-in inference provider#2535
zhaohuabing wants to merge 2 commits into
NVIDIA:mainfrom
zhaohuabing:feat/tars-provider

Conversation

@zhaohuabing

@zhaohuabing zhaohuabing commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds TARS (Tetrate Agent Router Service) as a built-in inference provider, following the DeepInfra precedent (#1902). TARS is a multi-tenant LLM traffic router that fronts ~200 models across upstream providers behind one endpoint, with server-side model routing, fallback chains, BYOK, budget enforcement, and per-key usage attribution.

One tars provider entry gives sandboxes all of that through inference.local, with the TARS key injected at the supervisor proxy and never present in the sandbox environment.

Related Issue

Changes

  • crates/openshell-core/src/inference.rsTARS_PROTOCOLS, TARS_PROFILE, normalize/profile arms, 3 new tests (+ tars added to the OpenAI-embeddings contract test)
  • providers/tars.yaml — Providers v2 profile (inference category, bearer credential, SaaS endpoint for policy injection)
  • crates/openshell-providers — discovery spec (TARS_API_KEY, AGENTROUTER_API_KEY), registry + built-in YAML registration
  • crates/openshell-core/src/telemetry.rs + crates/openshell-server/src/grpc/provider.rsTars telemetry bucket
  • crates/openshell-server/src/inference.rs — supported-types error message
  • Docs: providers-v2.mdx, manage-providers.mdx, architecture/gateway.md

Testing

  • mise run pre-commit passes
  • Unit tests added/updated
  • E2E tests added/updated (if applicable)
  • Tested locally on my dev machine:
~/workspace/OpenShell/target/debug/openshell --gateway-endpoint http://127.0.0.1:17690 provider create --name tars --type tars --credential TARS_API_KEY=$TARS_API_KEY
~/workspace/OpenShell/target/debug/openshell --gateway-endpoint http://127.0.0.1:17690 inference set --provider tars-real --model o3-mini
~/workspace/OpenShell/target/debug/openshell --gateway-endpoint http://127.0.0.1:17690 sandbox create --name tars-test
~/workspace/OpenShell/target/debug/openshell --gateway-endpoint http://127.0.0.1:17690 sandbox exec -n tars-test -- curl -s https://inference.local/v1/chat/completions -H 'Content-Type: application/json' -d '{"model":"anything","messages":[{"role":"user","content":"hi from openshell"}]}'
{
  "id": "chatcmpl-E6sodV8LIYMEaQDwhH6MXZ71IljqA",
  "object": "chat.completion",
  "created": 1785309387,
  "model": "o3-mini-2025-01-31",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hi there! How can I help you today?",
        "refusal": null,
        "annotations": []
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 151,
    "total_tokens": 161,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "audio_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 128,
      "audio_tokens": 0,
      "accepted_prediction_tokens": 0,
      "rejected_prediction_tokens": 0
    }
  },
  "service_tier": "default",
  "system_fingerprint": "fp_57f03b1976"
}

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

…n inference provider

- Adds `tars` as a built-in Providers v2 profile (`providers/tars.yaml`)
  with inference category, Bearer auth, and TARS_API_KEY /
  AGENTROUTER_API_KEY discovery
- Adds `TARS_PROFILE` to inference routing so `inference.local` works
  with the `tars` provider type. TARS serves OpenAI-compatible endpoints
  and the Anthropic Messages API on the same host, so the profile
  advertises both protocol families on a single route (precedent:
  google-vertex-ai) — OpenAI-SDK tools and Anthropic clients work in the
  same sandbox with one configured provider
- Default base URL is the Tetrate-hosted SaaS gateway
  (https://api.router.tetrate.ai/v1); enterprise deployments override it
  with `--config TARS_BASE_URL` (precedent: deepinfra's vendor default)
- Passes through anthropic-version, anthropic-beta, openai-organization,
  and x-model-id client headers
- Registers a tars provider plugin (discovery, known_types(), TUI), a
  Tars telemetry bucket, and normalize aliases (tars, agentrouter,
  tetrate-agent-router)
- Updates providers-v2.mdx, manage-providers.mdx, and
  architecture/gateway.md provider lists

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@zhaohuabing
zhaohuabing marked this pull request as ready for review July 29, 2026 07:57
Verified each protocol the TARS profile advertises against the live
endpoint. `POST /v1/completions` answers "Unsupported endpoint", so
drop `openai_completions` from the profile; chat completions,
responses, embeddings, and Anthropic messages all serve.

Record why `default_headers` stays empty on a dual-family profile:
route default headers apply to every request on the route regardless
of protocol, so injecting `anthropic-version` would also stamp it onto
the OpenAI-family paths TARS serves from the same base URL.

Add the `tars` row to the debug-inference skill, the TARS passthrough
set to the inference-routing header table, and the `agentrouter` /
`tetrate-agent-router` aliases to the provider table, with a
normalize_provider_type test pinning them.

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant