Agent harness

Models and keys

The agent harness runs on your own model and your own key. Harny names no model. This page lists the providers it accepts and how to set yours.

Copy page
View as Markdown

You choose the provider and the model. Harny does not pick a model for you and never sees your key. The Memory API needs no model at all: recall returns ranked evidence as JSON, and your own model writes the answer.

Set your model

Pass provider= and model= to Agent.create. You can set the same two values with the variables HARNY_MODEL_PROVIDER and HARNY_MODEL.

agent = await Agent.create(
    harny=harny,
    provider="your-provider",    # one of the providers in the table below
    model="your-model-id",       # the model id your provider gives you
    config=AgentConfig(instructions="You help one person with their calendar."),
)

Replace both values with the provider and the model you chose. The harness makes no request to Harny to look them up.

In the npm package the same options are provider, model, apiKey, baseUrl, apiStyle, priceInPerMtok and priceOutPerMtok.

Providers

Providerprovider=Key variableWire style
OpenAIopenaiOPENAI_API_KEYchat-completions
Anthropic ClaudeanthropicANTHROPIC_API_KEYmessages
Google GeminigoogleGEMINI_API_KEY, GOOGLE_API_KEYgenerate-content
Zhipu GLMzhipuZAI_API_KEYchat-completions
DeepSeekdeepseekDEEPSEEK_API_KEYchat-completions
OpenRouteropenrouterOPENROUTER_API_KEYchat-completions

Anthropic's endpoint can reach Harny's tools as a remote MCP server. With every other provider the harness calls Harny's tools from the client side.

Your key

The SDK reads your key from the provider's variable in the table. You can also set HARNY_MODEL_API_KEY, or pass api_key= in code. Harny never sees it.

Prices for the spend cap

A dollar spend cap needs a price. Pass the price of your model in dollars per million tokens: price_in_per_mtok= for input and price_out_per_mtok= for output. Pass both or neither.

Without prices the model is unpriced. A dollar cap is then not enforced, and the token cap applies instead. Every run always has a cap. Harny holds no price for the model you name.

Another provider

For a provider that is not in the table, pass base_url= with the provider's address. Add api_style= when the provider does not speak the chat-completions style. The values are chat_completions, messages and generate_content. The key comes from api_key= or HARNY_MODEL_API_KEY.

Change the model

A model swap is one setting on your side: change model=, or provider= and the key, and run again. Nothing stored in Harny changes, because memory does not depend on the model that reads it.

If you set no model

Agent.create stops with an error that names what to set: provider=, model= and your key variable.

Next