Skip to content

feat: Add AIMLAPI provider support to AI plugins #12379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 2, 2025

Conversation

D1m7asis
Copy link
Contributor

Description

This PR adds AIMLAPI as a supported provider to the ai-proxy, ai-proxy-multi, and ai-request-rewrite plugins in Apache APISIX. AIMLAPI provides a unified OpenAI-compatible API with access to 300+ LLMs such as GPT-4, Claude, Gemini, DeepSeek, and others.

Motivation

AIMLAPI is used by over 150,000 developers and organizations as a centralized LLM API gateway. It supports OpenAI-compatible request formats and offers strong uptime, competitive pricing, and access to a wide variety of models. This change enables APISIX users to easily route and proxy requests through AIMLAPI without needing custom drivers or overrides.

What's Changed

  • ✅ Added a new OpenAI-compatible driver: aimlapi.lua

  • ✅ Updated provider enums in:

    • ai-proxy schema
    • ai-request-rewrite schema
    • ai-proxy-multi schema
  • ✅ Updated documentation to reflect AIMLAPI as an officially supported provider

  • ✅ Clarified examples, usage, and endpoint behavior for AIMLAPI

  • ✅ Confirmed backwards compatibility and fallback behavior

Test Screenshots:
Screenshot 2025-06-24 192252
Screenshot 2025-06-24 192420

Which issue(s) this PR fixes:

#12289 — new provider integration


Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible

Introduced AIMLAPI as a supported provider in ai-proxy, ai-request-rewrite, and related schema and documentation. Added a new driver for AIMLAPI, updated provider enums, and clarified documentation to reflect AIMLAPI integration.
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request plugin labels Jun 25, 2025
Copy link
Contributor

@Baoyuantop Baoyuantop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add test cases to verify the provider aimlapi, such as https://github.com/apache/apisix/blob/master/t/plugin/ai-request-rewrite.t#L241.

If you are not familiar with test nginx, you can also use ts to complete the test. You can refer to https://github.com/apache/apisix/blob/master/t/plugin/mcp/bridge.spec.ts

If you have problems running the test locally, you can refer to this document to build the environment https://github.com/apache/apisix/blob/master/docs/en/latest/build-apisix-dev-environment-devcontainers.md

Introduces a new test case to verify schema validation when using the 'aimlapi' provider with authorization header in the ai-request-rewrite plugin.
@D1m7asis
Copy link
Contributor Author

@Baoyuantop Thanks for the note!

Test cases for provider = "aimlapi" have been added and verified.
They cover both validation and request behavior, similar to the existing ones for openai and deepseek.

Relevant test output:

ok 13 - TEST 5: provider must be one of: deepseek, openai, aimlapi, openai-compatible - status code ok
ok 14 - TEST 5: ... - response_body - response is expected
ok 15 - TEST 5: ... - pattern "[error]" does not match a line in error.log

ok 46 - TEST 15: provider aimlapi - status code ok
ok 47 - TEST 15: provider aimlapi - response_body - response is expected
ok 48 - TEST 15: provider aimlapi - pattern "[error]" does not match a line in error.log

@Baoyuantop
Copy link
Contributor

Hi @D1m7asis, there is a code lint error that needs to be fixed.

Reformatted the 'provider' enum lists in ai-proxy/schema.lua and ai-request-rewrite.lua to use multi-line arrays for improved readability and maintainability. No functional changes were made.
@Baoyuantop
Copy link
Contributor

Hi @D1m7asis, there is also a code lint error that needs to be fixed.

@D1m7asis
Copy link
Contributor Author

D1m7asis commented Jul 1, 2025

Sorry, didn’t notice that earlier - fixed the style issue in ai-request-rewrite.t

Let me know if anything else needs adjustment 🙌

Copy link
Contributor

@Baoyuantop Baoyuantop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it and it works.

@Baoyuantop Baoyuantop merged commit ff8c350 into apache:master Jul 2, 2025
26 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in ⚡️ Apache APISIX Roadmap Jul 2, 2025
@OctavianTheI
Copy link

@Baoyuantop @membphis @bzp2010
Guys, let me know if your team would like to capitalize on this integration with any crosspromo - we'd be glad to release a couple of tutorials and more

If that sounds interesting, please send the responsible person's email to sergey@aimlapi.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request plugin size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants