Use provider-specific proxy transports and catalog prices
This commit is contained in:
@@ -19,7 +19,31 @@ Without that provider, the definition or default family selects the model.
|
||||
No login fallback runs.
|
||||
|
||||
Existing registered models retain their transport.
|
||||
New logical model references reuse the host's OpenAI-compatible proxy provider and its auth resolver.
|
||||
New model references reuse a template from their own registered provider and retain its proxy auth resolver.
|
||||
They never inherit another provider's transport. Unknown providers fail instead of silently using OpenAI.
|
||||
Models absent from the catalog receive zero prices, not the template's prices.
|
||||
The extension never reads a credential or registers a direct provider SDK.
|
||||
|
||||
## Host proxy transports and prices
|
||||
|
||||
`host/js/proxy-models.ts` reads the authenticated `/v1/models` catalog once at host startup.
|
||||
OpenAI models use pi-ai's Responses transport. Anthropic models use its Messages transport.
|
||||
The catalog endpoint determines each model's base URL.
|
||||
For Anthropic, effort capabilities select adaptive thinking and its advertised effort levels.
|
||||
Both providers use the existing `llm-proxy` key and usage tag. No provider login or direct endpoint fallback runs.
|
||||
|
||||
If the catalog fails or exceeds five seconds, a small table supplies these defaults:
|
||||
|
||||
| Provider/model | API | Proxy path |
|
||||
| --- | --- | --- |
|
||||
| `openai/gpt-6.1-sol` | Responses | `/v1/responses` |
|
||||
| `anthropic/claude-opus-5-5` | Messages, adaptive thinking | `/apis/anthropic/v1/messages` |
|
||||
|
||||
Catalog prices use USD per million tokens, with conversion from `unit_tokens` when necessary.
|
||||
The host uses the first advertised route's quote, including cache reads and cache writes.
|
||||
These costs are estimates, not billing totals. Another proxy route can charge different prices.
|
||||
Unavailable prices remain zero. Catalog changes apply after a host restart.
|
||||
World family edits still apply at the next run boundary without a restart.
|
||||
`host/tests/proxy_models.rs` tests the real transports against a local fake proxy.
|
||||
|
||||
`host/tests/core_ext.rs` tests these services through the snapshot loader.
|
||||
|
||||
@@ -28,14 +28,15 @@ export default function models(host: any) {
|
||||
const found = discoverAgents(files, '/src/sausage', root, families, refs)
|
||||
return {families, ...found}
|
||||
}
|
||||
const transport = host.models().getProvider('openai')
|
||||
const template = host.models().getModels('openai')[0]
|
||||
const register = (ref: any) => {
|
||||
const store = host.models()
|
||||
if (store.getModel(ref.provider, ref.modelId)) return
|
||||
const transport = store.getProvider(ref.provider)
|
||||
const template = store.getModels(ref.provider)[0]
|
||||
if (!transport || !template) throw new Error(`No proxy transport for ${ref.provider}/${ref.modelId}`)
|
||||
const prior = store.getModels(ref.provider)
|
||||
store.setProvider({...transport, id:ref.provider, getModels:()=>[...prior, {...template, provider:ref.provider, id:ref.modelId, name:ref.modelId}]})
|
||||
store.setProvider({...transport, getModels:()=>[...prior, {...template, id:ref.modelId, name:ref.modelId,
|
||||
cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}]})
|
||||
}
|
||||
const apply = async (tx: any, id: number) => {
|
||||
const state = await tx.doc(AgentDoc, id)
|
||||
|
||||
Reference in New Issue
Block a user