Cut cost with openpike/auto
This recipe creates an alias named auto that always tries the cheapest of the models you trust first, so routine work costs less without code changes beyond the model name.
1. Choose models you trust for the task
Section titled “1. Choose models you trust for the task”Only list models that do the job well enough; cheapest-first will use the cheapest of them for every request. For summaries, classification or simple code edits, for example:
deepseek/deepseek-flashgoogle-ai-studio/gemini-3.6-flashopenai/gpt-5.4-mini
Each needs a provider key in the workspace, and each must have a price in OpenPike’s price table to be ordered by price: unpriced models go last. The provider pages show which models are priced.
2. Create the alias
Section titled “2. Create the alias”On Routing, create an alias named auto, format chat completions, with the models above and the policy cheapest_first. On each request, OpenPike orders the targets by input plus output price per million tokens from its current price table, cheapest first.
3. Send requests to it
Section titled “3. Send requests to it”curl -i https://api.openpike.dev/v1/chat/completions \ -H "Authorization: Bearer $OPENPIKE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "openpike/auto", "messages": [{"role": "user", "content": "Name one river in Europe."}] }'import os
from openai import OpenAI
client = OpenAI( base_url="https://api.openpike.dev/v1", api_key=os.environ["OPENPIKE_API_KEY"],)
raw = client.chat.completions.with_raw_response.create( model="openpike/auto", messages=[{"role": "user", "content": "Name one river in Europe."}],)completion = raw.parse()print("served by", raw.headers["x-openpike-model"], "after", raw.headers["x-openpike-attempts"], "attempt(s)")print(completion.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.openpike.dev/v1", apiKey: process.env.OPENPIKE_API_KEY,});
const { data, response } = await client.chat.completions .create({ model: "openpike/auto", messages: [{ role: "user", content: "Name one river in Europe." }], }) .withResponse();console.log("served by", response.headers.get("x-openpike-model"), "after", response.headers.get("x-openpike-attempts"), "attempt(s)");console.log(data.choices[0]?.message.content);The response headers say which model answered. If the cheapest model fails before answering, the next cheapest is tried, as with any alias.
4. Check the saving
Section titled “4. Check the saving”On Activity, group spend by model before and after the switch. Because OpenPike prices every request, you see what each model costs you per day.
When not to use it
Section titled “When not to use it”- For hard tasks, cheapest-first sends everything to the cheapest model, which may be the weakest. Keep a separate alias, such as
openpike/smart, with stronger models and theorderedpolicy, and choose per call. - Requests to unpriced models have no cost in OpenPike, so a cheapest-first alias tries them last, not first.