add support for 3rd party API's besides OpenRouter - #17
Open
SellPL wants to merge 4 commits into
Open
Conversation
SellPL
marked this pull request as draft
July 25, 2026 10:58
SellPL
marked this pull request as ready for review
July 25, 2026 11:06
riki137
requested changes
Jul 25, 2026
riki137
left a comment
Owner
There was a problem hiding this comment.
Thanks for the contribution. The protocol-discriminator approach makes sense, and the Anthropic request shape broadly matches the Messages API. However, this branch is not merge-ready; there are clear signs the generated changes were not properly reviewed.
- The history commits a 66.9 MB APK, the complete web build, and
node_modules, then deletes them later. Please rewrite/squash the branch before a merge/rebase so these blobs do not enter the repository history. - The final diff still contains unrelated
package.jsonandpackage-lock.jsonfiles with an unusedgitnpm dependency. These should be removed. Please also revert or explain the unrelatedandroid/gradle.propertiesandpubspec.lockchanges. .gitignore:56-57contains"node_modules/"and"dist/". Git treats those quotes literally, so the directories are not ignored. Usenode_modules/anddist/without quotes and clean up the trailing whitespace/line endings.- Switching from another free-text provider to Anthropic retains the previous model and fallback values:
updateProvider()only changes the provider ID. For example, switching from OpenAI withgpt-5.5and saving will sendgpt-5.5to the Anthropic endpoint. Provider changes need to reset or populate the model fields, with a regression test. - The added test only checks endpoint/protocol resolution. None of the important new behavior is exercised: Anthropic headers, top-level
system, image conversion, omission ofresponse_format, or response parsing. Please make HTTP injectable/mockable and test the actual outbound request and representative responses. AIServiceignores Anthropic’sstop_reasonand attempts to parse every HTTP 200 text block as food JSON.max_tokens,refusal, and context-limit responses need explicit handling. This matters particularly because Claude Opus 5 enables thinking by default and thinking counts against the hardcoded 2,048-token ceiling. Anthropic recommends always checkingstop_reason: stop-reason documentation, thinking documentation.
I ran the complete Flutter test suite against commit d59b062; it passes. The core idea is usable, but the branch hygiene and missing protocol-level tests need fixing before merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
this pull request adds support for other API's. Worked for me on android with 3rd party provider with claude opus 5 model. more from Claude Fable 5 about this since it was vibecoded:


PR notes:
▎ Add Anthropic (Claude) as a selectable AI provider
▎
▎ Anthropic speaks its own Messages API rather than OpenAI chat completions, so this adds a small protocol discriminator instead of pretending it's another base URL:
▎ - New AiApiProtocol enum; provider registry entry for Anthropic (/v1/messages, key hint sk-ant-..., suggested model claude-opus-5).
▎ - AIService branches per protocol: x-api-key + anthropic-version: 2023-06-01 headers, system prompt moved to top-level system, required max_tokens (2048), OpenAI-style data-URL images converted to base64
▎ image content blocks, reply text taken from the first content[].text block.
▎ - No response_format on Anthropic — relies on the existing strict-JSON prompt and the lenient parseModelJson recovery, unchanged.
▎ - anthropic-dangerous-direct-browser-access: true header so the web build works (BYO-key in browser is already this app's model on every provider).
▎ - Settings UI picks the provider up automatically from kAiProviders; public AIService API unchanged, so no caller edits. README/settings copy updated; unit test added for endpoint/protocol resolution.
▎
▎ Tested: flutter analyze clean, full test suite passes, web + Android release builds compile. Not tested: live calls against the Anthropic API (no key available) — request/response shapes follow current
▎ Messages API docs and want one manual verification.