Commit 1cfcf33
Route deepseek-v4-flash to Fireworks when DeepSeek API is unhealthy
Adds Fireworks as a transparent fallback for deepseek-v4-flash, gated by
a passive circuit breaker so we only divert when the official DeepSeek
API actually misbehaves.
- New deepseek-health.ts circuit breaker: 3 failures in 60s opens the
circuit for 5 min; the next request after expiry probes DeepSeek again
and resets on success. No background polling — every user request is
itself the probe.
- Tighter 60s headersTimeout for the Flash undici agent so dead-API
requests fail fast (the existing 30-min default is kept for reasoning
models on v4-pro).
- handleDeepSeek{Stream,NonStream} now wrap the fetch call so network
errors, timeouts, and 5xx/408/429 responses feed the breaker; 2xx
resets it.
- _post.ts routes to Fireworks when the circuit is open and adds inline
pre-stream failover so the first user to hit an outage also gets a
Fireworks response instead of an error.
- Adds accounts/fireworks/models/deepseek-v4-flash to the Fireworks
model + pricing maps.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 547e061 commit 1cfcf33
5 files changed
Lines changed: 405 additions & 5 deletions
File tree
- web/src
- app/api/v1/chat/completions
- llm-api
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
70 | 74 | | |
71 | 75 | | |
72 | 76 | | |
| |||
118 | 122 | | |
119 | 123 | | |
120 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
121 | 142 | | |
122 | 143 | | |
123 | 144 | | |
| |||
814 | 835 | | |
815 | 836 | | |
816 | 837 | | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
817 | 845 | | |
818 | 846 | | |
819 | 847 | | |
820 | 848 | | |
| 849 | + | |
821 | 850 | | |
822 | 851 | | |
823 | 852 | | |
| |||
841 | 870 | | |
842 | 871 | | |
843 | 872 | | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
844 | 890 | | |
845 | 891 | | |
846 | 892 | | |
| |||
850 | 896 | | |
851 | 897 | | |
852 | 898 | | |
853 | | - | |
| 899 | + | |
854 | 900 | | |
855 | 901 | | |
856 | 902 | | |
| |||
886 | 932 | | |
887 | 933 | | |
888 | 934 | | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
889 | 942 | | |
890 | 943 | | |
891 | 944 | | |
892 | 945 | | |
| 946 | + | |
893 | 947 | | |
894 | 948 | | |
895 | 949 | | |
| |||
914 | 968 | | |
915 | 969 | | |
916 | 970 | | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
917 | 985 | | |
918 | 986 | | |
919 | 987 | | |
| |||
923 | 991 | | |
924 | 992 | | |
925 | 993 | | |
926 | | - | |
| 994 | + | |
927 | 995 | | |
928 | 996 | | |
929 | 997 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
0 commit comments