Skip to content

Support multiple model providers, custom endpoints, and Kubernetes Secret references for API keys #516

Open

Description

@benjaminhuo

I would like AX to support model providers beyond Google, including OpenAI, Anthropic, etc., and services exposing compatible APIs.

The provider configuration should support:

  • Selecting the provider and model.
  • Configuring a custom API endpoint or base URL, including OpenAI-compatible services and self-hosted model gateways.
  • Reading the provider’s API key from a specified Kubernetes Secret.

AX already exposes a secretKey reference in its Model configuration. It would be useful to support an explicit Secret namespace and ensure the selected provider, endpoint, model, and credentials are used consistently throughout model execution, including workspace bootstrap.

For example, the following illustrates the desired configuration; the exact field names are open to discussion:

apiVersion: ax.io/v1alpha1
kind: Model
metadata:
name: default-model
atespace: default
spec:
provider: openai
model: my-model
baseURL: https://api.example.com/v1
secretKey:
namespace: kagent
name: kagent-my-provider
key: PROVIDER_API_KEY

The Kubernetes namespace containing the Secret should be independent of the AX/Substrate atespace. In this example, the Model belongs to atespace default, while its credentials come from the kagent Kubernetes namespace. Secret access should use the AX server’s Kubernetes identity and respect RBAC permissions.

Expected behavior:

  • Existing Google provider configurations continue to work.
  • OpenAI, Anthropic, and compatible custom endpoints can be configured through Model resources.
  • API keys are resolved from Kubernetes Secrets without embedding them in manifests.
  • Unsupported providers, invalid endpoints, and missing or inaccessible credentials produce actionable errors.

This would allow AX to work with existing enterprise model providers and credential management setups while keeping task execution configuration declarative.

Activity

  1. yjjnls commented on Nov 19, 2026

    @yjjnls

    Design input: what the current tree gives you, and the decisions this implies (af62e9d)

    Three current facts shape the request:

    Two credential models already exist side by side. Model.spec.secretKey is name/key only (pkg/apis/v1alpha1/model.proto:40-43) and is resolved from Kubernetes by the client (internal/model/client.go:270-297). Separately, Gateway egress rules with effects.replaceHeaders inject credentials at the network boundary by reference: the ate-secret://... URI shape appears in the in-tree validation tests (internal/apivalidation/gateway_test.go:36-39), cleartext-http and wildcard-host credential rules are rejected (internal/apivalidation/gateway.go:43-52), and a Kind E2E covers the path (#588). The hero demo uses exactly this (hack/hero-demo/task-starter.yaml:38 — a placeholder replaced by the bound Gateway). Under that pattern the sandbox never holds the key and rotation is a Gateway edit, not a task restart. What that pattern does not carry is per-tenant model metadata — model name, generation parameters — which is the part worth adding to ModelSpec.

    The missing Secret namespace is currently the access boundary. Resolution uses the Model's atespace as the Kubernetes namespace (internal/model/client.go:288-291), while the ax-server SA holds cluster-wide secrets get/list/watch (deploy/ax-server.yaml:29-35). Adding secretKey.namespace without a scope rule makes every Model a cross-namespace reference that the component resolving it — under that Role — can read. A narrow default (resolve only in the Model's atespace namespace, and make any other namespace an explicit allowlisted case with its own error) preserves the kagent-style use case and keeps "respects RBAC" meaningful. The same applies to custom endpoints: baseURL is a client option today (internal/model/client.go:71,208-212), not a ModelSpec field, so endpoint validation has no server-side home yet.

    Rotation and errors are the weak points of the Model path. Keys resolve once at client construction (internal/model/client.go:262-265), so long-lived consumers pin credentials until restart. The only implemented call path is Google's, which sends the key in the URL query string (internal/model/client.go:509); for custom endpoints, header-based auth or gateway injection keeps credentials out of URLs and logs. And docs already show provider: anthropic (docs/manifests.md:285-304) while the client rejects anything non-google as "unsupported provider" (internal/model/client.go:486-495); ValidateModel today checks only metadata (internal/apivalidation/model.go:22-26), so provider/endpoint validation at write time would make the "actionable errors" expectation real before a task spends a boot cycle discovering it.

    Consistency note: TaskSpec and WorkspaceSetup have no Model reference (pkg/apis/v1alpha1/workspace.proto:69-86), so whichever mechanism wins still needs an answer for "who resolves the Model for a given task run" — today it is whoever constructs the client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions