Commit Graph
226 Commits
Author SHA1 Message Date
9qeklajc 9ef01acac9 Merge branch 'main' into pr-reactive-correction 2026-06-07 13:10:29 +02:00
9qeklajc 06c8a071a5 feat: reactive request-correction retry for recoverable upstream 400s 2026-06-07 13:00:19 +02:00
9qeklajc 9e9c2bde57 fix: buffer-based SSE parser for all supported providers
Replace the fragile `re.split(b"data: ")` streaming parser with a
buffered, event-delimited parser in both the chat-completion and
Responses-API streamers. Events are accumulated until the SSE blank-line
delimiter, so parsing is independent of network chunk boundaries.

Fixes:
- OpenRouter `: OPENROUTER PROCESSING` keepalive comments no longer leak
  to clients as `data: : ...` (the `Unexpected token ':'` client crash).
- JSON payloads split across TCP reads are reassembled before parsing.
- CRLF framing (Gemini native alt=sse) handled.
- Combined content+usage chunks (Gemini thinking models over the
  OpenAI-compat endpoint) forward content once and still report usage in
  the cost trailer, instead of dropping the assistant message.
- Multi-line non-JSON `data` blocks are re-prefixed per line so they stay
  valid SSE framing for the client.

Adds tests/unit/test_streaming_sse_providers.py driving the real
generator against per-provider on-the-wire framing, and switches the
integration token-mint fallback to secrets.token_hex to kill a
PRNG/clock collision flake.
2026-06-07 12:58:54 +02:00
9qeklajc 4abd751f5f make sure model provider field naming is correct 2026-06-07 11:01:53 +02:00
9qeklajcandGitHub 8f89171db1 Merge pull request #541 from jeroenubbink/fix/lightning-invoice-key-constraints
fix: persist and propagate key constraints from Lightning invoices
2026-06-07 10:51:29 +02:00
Jeroen UbbinkandClaude Sonnet 4.6 feb76bc89d fix: persist and propagate key constraints from Lightning invoices
LightningInvoice had no columns for balance_limit, balance_limit_reset,
or validity_date. SQLModel silently dropped these constructor kwargs, so
create_api_key_from_invoice always produced an unconstrained key.

Add the three columns to LightningInvoice with a migration, and wire them
through to the ApiKey in create_api_key_from_invoice, matching the pattern
already used in the child key creation path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-03 14:58:40 +02:00
Jeroen UbbinkandClaude Sonnet 4.6 3b7f96560b fix: make child key balance deduction atomic
The previous in-memory deduction (key.balance -= cost) was a read-modify-
write on stale state, allowing two concurrent create_child_key() calls to
both pass the balance check and both succeed, effectively charging the
parent only once for two child keys.

Replace with an atomic UPDATE ... WHERE balance - reserved_balance >= cost
and check rowcount, matching the pattern already used in pay_for_request.
Also adds a concurrent integration test that reproduces the race and
confirms the fix holds.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-03 12:02:12 +02:00
9qeklajcandGitHub d7bf1d6582 Merge pull request #536 from Routstr/add-created-date-to-api-key
add api key creation date
2026-06-02 00:20:57 +02:00
9qeklajc 379c319e0d fix test 2026-06-01 23:30:20 +02:00
9qeklajc aaa80d47bc add api key creation date 2026-06-01 23:27:26 +02:00
9qeklajc 9633483fa4 prevent zero balance token 2026-06-01 22:47:09 +02:00
Bilthon f2ef63da62 refactor(balance): remove unreachable cashu-refund-by-hash endpoint 2026-05-28 10:25:25 -05:00
9qeklajcandGitHub 29cfeaed9a Merge pull request #523 from Routstr/rip-08-lightning-invoice
add rop-08 lightning invoice support
2026-05-21 00:28:41 +02:00
9qeklajc 632244e54f add rop-08 lightning invoice support 2026-05-20 23:24:24 +02:00
9qeklajc 3251664513 use correct var to report balance info 2026-05-20 23:00:03 +02:00
9qeklajc efb5719679 add provider field to response 2026-05-17 14:39:16 +02:00
9qeklajc 490687bb71 Merge branch 'main' into fix-provider-forwarding-upstream 2026-05-14 15:40:52 +02:00
9qeklajc 966613847e update not found proxy 2026-05-14 15:40:49 +02:00
9qeklajcandGitHub d030d86f9a Merge pull request #506 from Routstr/fix-swapping
fix swapping
2026-05-14 14:32:39 +02:00
9qeklajc 3c13be20cb no key creation when refund 2026-05-13 22:34:24 +02:00
9qeklajc 9d5e14903b fix swapping 2026-05-13 21:49:03 +02:00
9qeklajcandGitHub 27ec052c17 Merge pull request #499 from Routstr/emulate-claude-token-count
support /message/count_tokens endpoint
2026-05-10 08:45:58 +02:00
9qeklajcandGitHub 752d4f3803 Merge pull request #496 from Routstr/fix-provider-forwarding-upstream
fix provder forwarded path & wrong html response
2026-05-09 14:47:35 +02:00
9qeklajc 164ed775c8 support /message/count_tokens endpoint 2026-05-09 14:43:03 +02:00
9qeklajc 9d905758ec added page not found redirection 2026-05-09 14:07:45 +02:00
9qeklajc 6e9932e0ac fix provder forwarded path & wrong html response 2026-05-09 12:05:51 +02:00
9qeklajc 59773e972b configure payment 2026-05-09 00:00:18 +02:00
9qeklajc 4dbbb45240 add-missing-cache-token-to-calculation 2026-05-06 22:49:23 +02:00
9qeklajc a7615bc827 improve gemini upstream to forward /messages endpoint correctly 2026-05-04 00:48:52 +02:00
9qeklajc 37c2bea93d make sure to forward to the right upstream 2026-05-03 15:15:34 +02:00
9qeklajc 985e765285 fix gemini api 2026-05-02 21:24:27 +02:00
9qeklajc a4b1330627 clean up impl. & simplify 2026-05-02 16:46:39 +02:00
9qeklajc 309bc873e6 Merge branch 'main' into litellm-integration-for-anthropic-messages-forwarding 2026-05-01 16:30:13 +02:00
9qeklajc 66421cd17f normalize response 2026-04-28 00:44:22 +02:00
9qeklajc 8c0ac499ef make sure to always emit sats cost 2026-04-28 00:01:27 +02:00
9qeklajc 92d581573d test: add unit tests for litellm messages dispatch 2026-04-26 22:45:22 +02:00
9qeklajcandGitHub 28d91227af Merge pull request #475 from Routstr/admin-token
Admin token
2026-04-26 22:32:21 +02:00
9qeklajc a2db3e2d57 fmt 2026-04-26 22:19:30 +02:00
9qeklajc 689a07f562 enforce-models-refresh-from-upstream 2026-04-26 21:41:38 +02:00
9qeklajc 1f2ff8a99c added admin token 2026-04-25 11:18:58 +02:00
9qeklajc aa682bf8ec fix test 2026-04-22 23:43:11 +02:00
9qeklajc afd81aeca2 reduce retries 2026-04-22 23:14:45 +02:00
9qeklajc fa7d2804bb add test 2026-04-22 23:00:04 +02:00
9qeklajc 05115c3387 add api-key history and fix race condition while topup 2026-04-22 21:50:22 +02:00
9qeklajc 9f55da9bb8 make streaming serialization more robust 2026-04-14 00:44:10 +02:00
9qeklajc 963ee04619 enforce no swap when token from primary mint 2026-04-14 00:29:54 +02:00
9qeklajc 85a1ea4b4c add apikey refund tracking 2026-04-10 15:34:19 +02:00
9qeklajc a637acd8f4 use db fixture 2026-04-09 23:08:01 +02:00
9qeklajc 58be0c7976 clean u 2026-04-09 20:42:36 +02:00
9qeklajc 74b58e5fa3 add some tests and improve payment handling 2026-04-09 20:25:43 +02:00