Skip to content

When adding new provider proxyng Anthropic, Vix looks for ANTROPIC_API_KEY #59

Description

@hugosenari

When adding new provider (LLMGateway), using anthropic/haiku, vix, returns a error that no ANTROPIC_API_KEY is set even, setting env_key in proviter as LLMGTWAY_API_KEY


@kirby88 (adding your comment here):

@hugosenari This one is actually a separate thing from the bug this issue tracks, and it's a configuration/routing detail rather than a bug.

vix picks the provider for a model purely from the model spec's prefix, not from which provider you added. So a model named anthropic/haiku always routes to the built-in Anthropic provider (whose credential is ANTHROPIC_API_KEY), your custom LLMGateway provider and its LLMGTWAY_API_KEY are never consulted, because the spec doesn't start with that provider's model_prefix.

To route through your gateway, give it a unique model_prefix and reference the model by it:

{
  "id": "llmgateway",
  "display_name": "LLM Gateway",
  "model_prefix": "llmgateway",
  "wire_format": "chat_completions",
  "inference": { "base_url": "https://your-gateway/v1" },
  "credential_methods": [
    { "kind": "api_key", "env_var": "LLMGTWAY_API_KEY" }
  ],
  "models": [
    { "spec": "llmgateway/haiku", "display_name": "Haiku (via gateway)" }
  ]
}

Then select llmgateway/haiku (not anthropic/haiku) and it'll use LLMGTWAY_API_KEY.

Note you can't reuse anthropic as your gateway's model_prefix, vix rejects duplicate prefixes at load with a model_prefix ... collides between providers error.

If switching to a distinct prefix fixes it for you, this is working as intended. The original bug in this issue (env var ignored unless a keyring value is set) is a different problem and is already fixed for the next release.


I don't think is the case, spec should be 'anthropic/haiku'

Image

Or maybe the issue wasn't with spec, but with wire_format, I set it as 'messages' (https://github.com/get-vix/vix/blob/main/PROVIDERS.md#wire-formats-wire_format)

Image

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