spring-projects / spring-projects/spring-ai
OpenRouter reasoning field support
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
Expected Behavior
Currently we are using OpenRouter to access models, As OpenAI compatiable API.
Therefore, it would be great if it could be compatible with OpenRouter's API.
Current Behavior
What OpenRouter response:
{
"id": "gen-1768528898-MKtgrOMD5dK6dq3iyOSh",
"provider": "Google",
"model": "google/gemini-3-flash-preview",
"object": "chat.completion.chunk",
"created": 1768528898,
"choices": [
{
"index": 0,
"delta": {
"role": "assistant",
"content": "",
"reasoning": "**Deciding on Initial Action**\n\nI've decided to first query the ...",
"reasoning_details": [
{
"index": 0,
"type": "reasoning.text",
"text": "**Deciding on Initial Action**\n\nI've decided to first query the ...",
"format": "google-gemini-v1"
}
],
"annotations": []
},
"finish_reason": null,
"native_finish_reason": null,
"logprobs": null
}
]
}
For doc: https://openrouter.ai/docs/guides/best-practices/reasoning-tokens
What current ChatResponse get:
{
"metadata": {
"id": "gen-1768528898-MKtgrOMD5dK6dq3iyOSh",
"model": "google/gemini-3-flash-preview",
"rateLimit": {
"requestsLimit": 0,
"requestsRemaining": 0,
"requestsReset": "PT0S",
"tokensRemaining": 0,
"tokensLimit": 0,
"tokensReset": "PT0S"
},
"usage": {
"promptTokens": 0,
"completionTokens": 0,
"nativeUsage": {},
"totalTokens": 0
},
"promptMetadata": [],
"empty": false
},
"results": [
{
"metadata": {
"finishReason": "",
"contentFilters": [],
"empty": true
},
"output": {
"messageType": "ASSISTANT",
"metadata": {
"role": "ASSISTANT",
"messageType": "ASSISTANT",
"refusal": "",
"finishReason": "",
"index": 0,
"annotations": [],
"id": "gen-1768528898-MKtgrOMD5dK6dq3iyOSh",
"reasoningContent": ""
},
"toolCalls": [],
"media": [],
"text": ""
}
}
],
"result": {
"metadata": {
"finishReason": "",
"contentFilters": [],
"empty": true
},
"output": {
"messageType": "ASSISTANT",
"metadata": {
"role": "ASSISTANT",
"messageType": "ASSISTANT",
"refusal": "",
"finishReason": "",
"index": 0,
"annotations": [],
"id": "gen-1768528898-MKtgrOMD5dK6dq3iyOSh",
"reasoningContent": ""
},
"toolCalls": [],
"media": [],
"text": ""
}
}
}
Want to retrieve the data from the reasoning, but the currently returned data structure does not contain it.
Contributor 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.
Research direction
Start by locating the OpenAI-compatible chat response mapping that produces ChatResponse, then compare its handling of content with OpenRouter's reasoning and reasoning_details fields. Confirm the reasoning text is retained in the returned response and add focused coverage for a streaming chunk shaped like the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- ai, api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100