MCPcopy
hub / github.com/Doorman11991/smallcode / applyMaxTokensRename

Function applyMaxTokensRename

test/provider_compat.test.js:196–205  ·  view source on GitHub ↗
(body, baseUrl)

Source from the content-addressed store, hash-verified

194test('max_tokens → max_completion_tokens for OpenAI cloud o1/o3/o4', () => {
195 // Simulating the rename logic from bin/smallcode.js:
196 function applyMaxTokensRename(body, baseUrl) {
197 const _bUrl = (baseUrl || '').toLowerCase();
198 const _isOpenAICloud = _bUrl.includes('api.openai.com') || _bUrl.includes('openrouter.ai');
199 const _modelLower = String(body.model || '').toLowerCase();
200 const _isReasoning = /(^|[\/\-_])(o1|o3|o4)/.test(_modelLower);
201 if (_isOpenAICloud && _isReasoning && body.max_tokens && !body.max_completion_tokens) {
202 body.max_completion_tokens = body.max_tokens;
203 delete body.max_tokens;
204 }
205 }
206
207 const body1 = { model: 'o3-mini', max_tokens: 8192 };
208 applyMaxTokensRename(body1, 'https://api.openai.com/v1');

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected