Plugins / Providers
elelem-anthropic
Claude, direct or on Vertex.
Connects elelem to Claude through the Anthropic Messages API, or through Google Cloud Vertex AI. One gem, two providers.
gem install elelem-anthropicelelem-anthropic connects elelem to Claude. It registers two providers:
anthropic calls the Anthropic Messages API with your API key, and
vertex calls the same models through Google Cloud Vertex AI with your
gcloud credentials. Use it when you want a hosted model and already pay
Anthropic or Google.
Install #
gem install elelem elelem-builtins elelem-anthropicelelem-builtins is optional but gives the agent its default tools.
Requires Ruby 4.0.
Configure #
For the Anthropic API, set your key:
export ANTHROPIC_API_KEY=sk-ant-...For Vertex AI, log in with application default credentials and name your project:
gcloud auth application-default login
export GOOGLE_CLOUD_PROJECT=my-projectThe vertex provider runs gcloud auth application-default print-access-token
before every request and sends the result as a bearer token, so gcloud
must be on your PATH.
--model overrides ANTHROPIC_MODEL or VERTEX_MODEL. The defaults are
whatever model IDs the gem shipped with. Pass --model if you want a
specific or newer model.
Use #
elelem -p anthropic
elelem -p anthropic --model claude-sonnet-4-5
elelem ask -p anthropic "summarize the README"When you pass -p anthropic, elelem requires elelem/anthropic on demand.
That file registers both providers, but -p vertex makes elelem look for
elelem/vertex, which does not exist. Load the gem first with a plugin
file:
mkdir -p ~/.agents/plugins
echo 'require "elelem/anthropic"' > ~/.agents/plugins/anthropic.rb
elelem -p vertexelelem loads every .rb file in ~/.agents/plugins and .agents/plugins
before it builds the provider.
The gem also installs elelem-anthropic, which is elelem with
anthropic as the default provider:
elelem-anthropic chat
elelem-anthropic ask "what does lib/elelem/cli.rb do?"Unlike elelem, elelem-anthropic does not load elelem-builtins, so the
agent has no tools unless a plugin file adds them.
How it works #
Both providers share one class, Elelem::Anthropic::Provider. Each turn is
one POST with stream: true and max_tokens: 64000, made with
Net::HTTP. The read timeout is 3600 seconds and the open timeout is 10.
anthropicposts tohttps://api.anthropic.com/v1/messageswithanthropic-version: 2023-06-01.vertexposts tohttps://REGION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/REGION/publishers/anthropic/models/MODEL:rawPredict. The model goes in the URL, and the body carriesanthropic_version: vertex-2023-10-16instead of amodelfield.
Before sending, the provider moves the system message into the system
field, turns elelem’s tool results into tool_result blocks, and turns
assistant tool calls into tool_use blocks. Tools are sent with their
JSON schema as input_schema, and only when there are tools to send.
The response is read as server-sent events. Text deltas become the reply,
thinking_delta events are printed as thinking, and input_json_delta
fragments are joined and parsed into tool calls when the stream ends.
elelem prints thinking as it arrives and the reply once the turn is done.
Limitations #
- The request never enables extended thinking, so thinking text only appears if the API sends it unasked.
max_tokensis fixed at 64,000. There is no setting for it, temperature, or other sampling parameters.- Any non-2xx response raises
HTTP CODE: BODY. There are no retries. - No prompt caching: the request sets no
cache_control. -p vertexneedselelem/anthropicloaded first (see above).
Development #
git clone https://git.mokhan.ca/elelem/anthropic.git
cd anthropic
bin/setup
bin/test
bin/lintThe spec injects a fake HTTP adapter, so the tests make no network calls.
Environment #
| Variable | Default | Description |
|---|---|---|
ANTHROPIC_API_KEY | none | Required for -p anthropic. Sent as the x-api-key header. |
ANTHROPIC_MODEL | claude-opus-4-5-20250514 | Model for -p anthropic when –model is not given. |
VERTEX_MODEL | claude-opus-4-5@20251101 | Model for -p vertex when –model is not given. Part of the request URL. |
GOOGLE_CLOUD_PROJECT | none | Required for -p vertex. The Google Cloud project that hosts the model. |
GOOGLE_CLOUD_REGION | us-east5 | Vertex AI region for -p vertex. |