For centralized requests, markKeyOnError extracts an OpenAI SDK error from err and marks the key based on its status code. Returns true if the status was a key-specific failover trigger so callers can retry with the next key.
(ctx context.Context, key *keypool.Key, err error)
| 219 | // code. Returns true if the status was a key-specific failover |
| 220 | // trigger so callers can retry with the next key. |
| 221 | func (i *interceptionBase) markKeyOnError(ctx context.Context, key *keypool.Key, err error) bool { |
| 222 | if i.cfg.KeyPool == nil { |
| 223 | return false |
| 224 | } |
| 225 | var apiErr *openai.Error |
| 226 | if !errors.As(err, &apiErr) { |
| 227 | return false |
| 228 | } |
| 229 | return keypool.MarkKeyOnStatus( |
| 230 | ctx, key, apiErr.Response, |
| 231 | i.logger, i.providerName, |
| 232 | ) |
| 233 | } |
| 234 | |
| 235 | func (i *interceptionBase) hasInjectableTools() bool { |
| 236 | return i.mcpProxy != nil && len(i.mcpProxy.ListTools()) > 0 |