Repository navigation
Conversation
Y-API is an OpenAI-compatible gateway that fronts several vendors behind one
endpoint and API key, so model ids keep their vendor prefix:
client.chat.completions.create(
model="yapi:deepseek/deepseek-v4-flash", messages=messages
)
The provider follows the OpenAI-compatible pattern used by deepseek/openrouter
and reuses the openai SDK, so it needs no new dependency. It also wires up
native async and streaming via openai.AsyncOpenAI rather than falling back to
the base class's thread offload.
The base URL is set with setdefault (not assignment), so an alternative gateway
can be pointed at via base_url in config or the YAPI_API_BASE env var.
Adds the `yapi` extra (["openai"], as deepseek/ollama/lmstudio already do) and
nine tests, including ones asserting the factory can still resolve the provider
from the filename convention — a rename there breaks discovery without failing
any import.
Author
|
Gentle bump — opened Sep 19, no activity since. The change is self-contained: a provider entry in the registry plus the OpenAI-compatible wiring, in the same shape as the other gateway providers. I can rebase onto current main if that helps. For verification context (running now, on today's live gateway): a non-streaming |
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.
What this adds
A Y-API provider. Y-API is an OpenAI-compatible gateway that fronts several vendors behind
one endpoint and API key, so model ids keep their vendor prefix:
Discovery is automatic — per the README's "Extending aisuite" section,
yapi_provider.py→"yapi"→ classYapiProvider, so there is no registry to edit.Files
aisuite/providers/yapi_provider.pytests/providers/test_yapi_provider.pypyproject.tomlyapi = ["openai"]extraNo new dependency. It reuses the
openaiSDK, following the same OpenAI-compatiblepattern as
deepseek_provider.py/openrouter_provider.py. Theyapiextra mirrors whatdeepseek,ollamaandlmstudioalready declare (["openai"]);allneeds no changebecause it already pulls in
openai.Three choices worth flagging
base_urlusessetdefault, not assignment.deepseek_provider.pydoesconfig["base_url"] = "https://api.deepseek.com", which silently overrides an explicitbase_url. Since a gateway endpoint is exactly the thing someone might want to pointelsewhere (self-hosted, alternative deployment), this provider only defaults it — from
YAPI_API_BASEif set, otherwise the gateway.Async and streaming are wired up natively, via
openai.AsyncOpenAI, rather thanfalling back to
Provider's default thread offload.openai_provider.pydoes this, andsince Y-API speaks OpenAI's wire format there's no reason to take the slower path.
No docs change.
docs/chat-completions-quickstart.mdsays "The list of supportedproviders lives in
aisuite/providers/(<provider>_provider.py)" — the directory is thelist, so nothing else needs updating.
How this was tested
The nine tests cover: default endpoint,
base_urloverride from config,base_urlfromYAPI_API_BASE, the missing-keyValueError, a mocked completion, usage parsing,streaming pass-through, and — the two that matter most — that
ProviderFactory.create_provider("yapi")still resolves and that
"yapi"appears inget_supported_providers(). A rename thatbreaks the filename convention would not fail any import, so it is asserted explicitly.
Baseline control. My local env only has the
openaiSDK, so many provider tests can'tcollect. I therefore diffed the failure/error set with and without my two files (moving
them aside, not
git stash):So the change is exactly +9 passing tests with no new failures — the 11 pre-existing
failures are unrelated to this PR.
black --checkpasses on both new files (CI runspsf/black@stable).The tests are hermetic: the autouse fixture clears
YAPI_API_BASE, sotest_yapi_provider_defaults_to_the_gateway_endpointstill passes if that variable is setin the ambient environment (verified by running the suite with it exported to a
deliberately wrong value).