Skip to content

feat: read base URL and default model from the environment - #19

Draft
simonx1 wants to merge 1 commit into
obie:mainfrom
simonx1:feat/base-url-and-model-env-vars
Draft

simonx1 wants to merge 1 commit into
obie:mainfrom
simonx1:feat/base-url-and-model-env-vars

Conversation

@simonx1

@simonx1 simonx1 commented Sep 18, 2026

Copy link
Copy Markdown

The official Typesafe SDKs read three variables: TYPESAFE_API_KEY, TYPESAFE_BASE_URL and TYPESAFE_DEFAULT_MODEL. This client read the first and ignored the other two.

So a process already configured for the Python or JavaScript SDK — pointed at a staging base, or pinned to a versioned model id — silently got production and jev-latest here. Which is the worst way to be inconsistent: it works.

Providers declare the names with base_url_env and default_model_env, both nil by default so a hand-written provider keeps the old behaviour. OpenRouter gets the matching pair under its own prefix.

Precedence is the same for both: an explicit argument, then the environment, then the built-in default. A blank value counts as unset, so an exported-but-empty variable doesn't point the client at "". A model that comes from the environment goes through the provider's aliases like any other.

Tests

test/provider_env_test.rb, 12 cases, including that one provider's variable never reaches another.


Draft: part of a security and API-coverage audit, opened for reference rather than as a request for immediate review. Independent of the other branches, each off main. Suite green on Ruby 3.2.11, 3.3.8 and 3.4.8.

🤖 Generated with Claude Code

The official Typesafe SDKs read three variables: TYPESAFE_API_KEY,
TYPESAFE_BASE_URL, and TYPESAFE_DEFAULT_MODEL. This client read the first
and ignored the other two, so a process already configured for the Python
or JavaScript SDK -- pointed at a staging base, or pinned to a versioned
model id -- silently got production and jev-latest here, which is the
worst way to be inconsistent: it works.

Providers declare the names with base_url_env and default_model_env,
both nil by default so a hand-written provider keeps the old behaviour.
OpenRouter gets the matching pair under its own prefix.

Precedence is the same for both: an explicit argument, then the
environment, then the built-in default. A blank value counts as unset, so
an exported-but-empty variable does not point the client at "". A model
that comes from the environment goes through the provider's aliases like
any other.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.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