Detect OpenAI Reasoning Models and Adjust Request Payload
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- backend-api-design
Research direction
Start in packages/models/src/providers/openai.ts, where the issue says the request payload is built, and add the model detection helper and conditional payload fields described in the issue. First inspect the existing payload construction and nearby tests, then add coverage for reasoning and standard model branches. Done means both branches use the specified fields and prompt role, with the requested typecheck, test, and lint commands passing.
Written by the indexing model from the issue text.
Description
Goal
Add a helper function that detects whether an OpenAI model identifier refers to a reasoning model, and use it to conditionally adjust the request payload sent in packages/models/src/providers/openai.ts.
Background
OpenAI reasoning models (o1, o3, o3-mini, o4-mini, and future variants) reject the temperature parameter and require max_completion_tokens instead of max_tokens. The current adapter sends both unconditionally, causing HTTP 400 errors for any reasoning model.
This sub-issue is part of the parent issue: OpenAI adapter incompatible with reasoning models.
What to Build
Add an isOpenAIReasoningModel(model: string): boolean helper in the openai provider:
function isOpenAIReasoningModel(model: string): boolean {
const lower = model.toLowerCase();
return (
/^o\d/.test(lower) || // o1, o3, o3-mini, o4-mini, o5, etc.
lower.includes("-reasoning") || // possible future naming convention
lower.startsWith("gpt-6") // gpt-6 and variants when in reasoning mode
);
}
Then update the body payload construction to branch on isReasoning:
const isReasoning = isOpenAIReasoningModel(model);
const bodyPayload: Record<string, unknown> = {
model,
messages: [
{ role: isReasoning ? "developer" : "system", content: prompts.system },
{ role: "user", content: prompts.user },
],
...(isReasoning
? { max_completion_tokens: effectiveCeiling }
: { temperature, max_tokens: effectiveCeiling }),
response_format: { type: "json_object" },
};
Done When
-
isOpenAIReasoningModelcorrectly identifies o-series and gpt-6 models - Standard models (
gpt-4o,gpt-5, custom endpoints) return false and are unaffected - Reasoning models receive
max_completion_tokensand notemperature - Standard models receive
temperatureandmax_tokensas before -
role: "developer"is used for the system prompt on reasoning models - Unit tests cover the detection helper and both branches of the payload builder
-
npm run typecheck,npm test, andnpm run lintall pass
- Dominant language
- TypeScript
- Stars
- 125
- Forks
- 23
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 12
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from devarshishimpi/codra
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
devarshishimpi/codra#178 ·
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 4/5 3-5 days Newbie friendliness 48/100
devarshishimpi/codra#186 ·
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 4/5 3-5 days Newbie friendliness 55/100
devarshishimpi/codra#185 ·
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 4/5 3-5 days Newbie friendliness 58/100
devarshishimpi/codra#184 ·
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 3/5 1-2 days Newbie friendliness 62/100
devarshishimpi/codra#183 ·
Maintainers usually reply within 1 day
All issues in devarshishimpi/codra
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
hemilabs/ui-monorepo#2711 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
code-yeongyu/senpi#6929 ·
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 72/100
lingdojo/kana-dojo#34261 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
embedpdf/embed-pdf-viewer#1116 ·
Maintainers usually reply within 1 day
-
current task
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
Sunday-School-Software/Sunday-School-Scheduler#87 ·
Maintainers usually reply within 1 day