Claude rejects tools whose input_schema has oneOf, anyOf or allOf at the
top level (400 "input_schema does not support oneOf, allOf, or anyOf at
the top level"). Codex Desktop's automation_update tool has such a schema,
so every Responses -> Claude turn that carried it failed.
FunctionParametersToInputSchema now merges the branches into one object
schema: properties are combined (differing same-name schemas go into a
nested anyOf), required is the intersection for oneOf/anyOf and the union
for allOf plus the top level's, and other top-level keywords are kept.
The tool conversion reports claude_top_level_schema_union_flattened.
Schemas without a top-level union are returned byte for byte.
* fix(gemini): bill audio inlineData by length, not as images, when usage is missing
When upstream reported no completion tokens (no usageMetadata, or
prompt-only usageMetadata), every inlineData part with a non-empty
mimeType was counted as an image and backfilled with 1400 completion
tokens. A relay that answered a text request with thousands of
audio/l16 TTS chunks was billed millions of output tokens.
Estimate inline output from the payload instead, on the stream and
non-stream paths alike:
- image* parts (case-insensitive) keep the 1400-token estimate;
- PCM audio (audio/l16 or audio/pcm with a rate) counts 25 tokens per
second, Gemini's audio token rate, measured from the decoded byte
count of valid base64 holding whole 16-bit samples, and is recorded
as audio output so tiered expressions price it with ao; on the
prompt-only path it replaces any upstream AUDIO candidate entry;
- audio without a measurable length and other media add nothing.
Responses that report completion tokens are unchanged.
* fix(gemini): harden inline media usage fallback and avoid redundant scan
- Parse inlineData MIME types once with mime.ParseMediaType and ignore empty image payloads
- Gate BillingUsage AUDIO detail replacement on inline fallback application so stale AUDIO entries are cleared when estimating images
- Defer inline media observation in buildUsageFromGeminiResponse until completion tokens are missing
- Saturate audio token conversion inside audioTokens via common.QuotaFromFloat without bare int casts
- Add regression cases for empty image payloads, stale AUDIO clearing on image fallback, and preserving upstream completion counts
---------
Co-authored-by: seefs001 <i@seefs.me>
* fix(claude): map output_tokens_details.thinking_tokens to reasoning_tokens
Anthropic reports thinking tokens in usage.output_tokens_details.thinking_tokens,
a subset of output_tokens. ClaudeUsage had no such field, so OpenAI-format
responses converted from a Claude channel always reported
completion_tokens_details.reasoning_tokens = 0.
Decode the field and carry it into CompletionTokenDetails.ReasoningTokens for
non-stream responses and stream message_start/message_delta usage, bounded by
output_tokens. completion_tokens and billing are unchanged.
* fix(claude): apply reported zero thinking_tokens on message_delta
message_delta usage is cumulative. When output_tokens_details is present, use its thinking_tokens even if zero; keep the earlier count only when the breakdown is absent.
* fix(claude): bound delta thinking_tokens by merged output and preserve on merge
- Clamp message_delta thinking_tokens against accumulated completion_tokens so deltas omitting output_tokens do not zero out reasoning_tokens.
- Copy incoming OutputTokensDetails in MergeClaudeUsageNonZero to preserve or replace the breakdown across usage merges.
---------
Co-authored-by: forgottener <8578113+forgottener@users.noreply.github.com>
Co-authored-by: seefs001 <i@seefs.me>
* fix(relaykit): report cached tokens in Gemini usageMetadata built from chat usage
Gemini promptTokenCount includes cached content, but responses converted
from chat usage (e.g. a Claude channel serving a Gemini-format request)
always reported cachedContentTokenCount as 0 while billing_usage carried
the cache read. Fill cachedContentTokenCount from the chat usage cache-read
count in the non-stream, stream chunk, and stream state converters.
* fix(relaykit): ignore non-positive cached token counts for Gemini usage
---------
Co-authored-by: seefs001 <i@seefs.me>
Verify that the callback pid matches the configured Epay PartnerID when RSA signing mode is enabled across EpayNotify, SubscriptionEpayNotify, and SubscriptionEpayReturn.
MD5 callbacks preserve existing behavior, and mismatched or missing RSA callback pid values are logged and rejected before settlement.
* fix(auth): reject API keys of deleted users with 401
Self-deleting an account soft-deletes the user but keeps its API keys.
TokenAuth and TokenAuthReadOnly treated the missing user as a database
failure and answered 500 "database error"; answer 401 invalid token
instead, the same as an unknown key.
* test(auth): cover deleted-user keys with a warm Redis user cache
Treat gemini-4-hydrogen as a thinkingLevel model so cross-protocol requests apply the requested strength. Pass xhigh and max through on hydrogen, pass max through on argon, and keep mapping minimal to low on both.
Closes#8364
Gemini may split one answer across several text parts. The Chat
converters inserted a newline between consecutive text parts and
dropped parts that were exactly "\n", so JSON split inside a key,
string, number or escape reached clients as invalid JSON, and other
text was silently altered.
Plain text parts are now written as-is and empty parts add nothing;
only rendered media, code and stream thought blocks keep their newline
separation. Grounding citations use the byte offsets recorded while
rendering instead of searching the output, so preserved newlines next
to those blocks are cited at their real position.
Share cache pricing labels across the editor, pricing pages, usage logs, and estimator. Distinguish GPT 30m/12h, Claude 5m/1h, generic cache reads, and custom configurations while preserving existing prices.
Add regression coverage and translations for all seven locales. Verified 832 related tests, focused final UI tests, type checking, lint, production build, and desktop/mobile browser checks.
Rebuild abilities from the channels read through the same transaction that updates their tags. Add regression cases for setting and clearing tags, preserving routing fields, and leaving unselected channels unchanged.
Validation: go test ./model -count=1 -v -run 'TestBatchSetChannelTag|TestUpdateChannelStatus|TestChannelOtherInfo' passed with SQLite 3.50.4, MySQL 8.0.46, and PostgreSQL 16.15. The regression fails against the previous implementation.
Errors new-api raises itself because of the request no longer count
against the channel:
- A param override condition that meets a request value of another type
(for example a string temperature in a numeric gt rule) now returns a
400 invalid_request that is not retried, instead of
channel:param_override_invalid, which was retried on every channel and
could auto-disable each of them. Invalid rules that fail every request
(non-numeric rule value, unsupported mode) stay channel errors.
- Image conversion failures use the shared convert-request-failed error,
so they are no longer retried on other channels.
- Automatic channel disabling skips errors classified as local by the
request policy log, so a local status or a disable keyword echoed from
client input cannot disable a channel. Upstream responses that adaptors
report as new-api errors, and local wrappers around an upstream error,
keep their upstream classification. The logged health entry now uses
the same decision.
Move the out-of-scope list, filing gates, required facts, and writing
rules from the agent templates into .agents/github/CHECKS.md, so the
posted body keeps only Agent, Request summary, Summary, Evidence, and
Merge Danger or Blast Radius.
Replace the verbatim user request with a short summary, collapse the
Agent block to one line, and require a diagram in Summary when a PR
changes a flow, call chain, state, or layout.
An instance with a plugin scope runs where both the confirmed scope and
the scope its plugin declares now hold the request. The two lists were
intersected word for word, so a confirmed gpt-4o and a declared
gpt-4o@effort:high shared nothing and the instance was skipped for
gpt-4o@effort:high, which both hold. Each scope now matches the request
on its own, modifiers included, and the instance runs when both match.
The docs also say that a task submitted before a scope change still
reports to the instances it stored, as for hand-placed instances.
* feat(plugins): let request plugins declare where they run
A request processing plugin can declare meta.scope: the models and
channel types it is made for. An administrator confirms that scope once
("Where the plugin suggests") and the instance then runs on every
matching request, new channels and models included. The instance runs
only where both the confirmed scope and the plugin's current scope hold,
so an update that narrows the scope applies at once and one that widens
it waits until an administrator confirms it again. The save API accepts
only the declared scope or the one saved before.
Instances placed by hand work as before.
* feat(plugins): let several plugins declare one channel type
A built-in channel type used to belong to one plugin: a second plugin
declaring it was rejected with "channelType N conflicts". Community
plugins for the same vendor (several Zhipu plugins, say) could not be
enabled together.
Now every plugin declaring a channel type is indexed for it. A channel
of the type serves each of them: its plugin extensions list their models,
and a request runs the plugin whose model it asks for, the first in key
order when several share the model. Model names that differ only in case
and protocol clashes still conflict.
The plugin site's marketplace list shows meta.description on one line
and cuts longer summaries off with an ellipsis. Measured on the live
list at desktop width, the summary column is 572 px at 14 px: 40 Chinese
characters fit and 41 do not, and real summaries of up to 80 columns
(CJK and full-width punctuation counting as two) all fit.
Add a "Plugin summary length" section to the API reference recommending
at most 80 columns per locale, with guidance on what to leave to the
usage guide, and point the manifest table and the Meta type at it.
A fieldset's default min-width is its content width, so a long line in
the plugin settings JSON editor widened the fieldset past the grid
column and pushed the plugin settings out of the channel drawer. Set
min-w-0 so the fieldset shrinks with its column and the editor scrolls
long lines itself.