Skip to content

feat(provider): add support for azure openai provider#1422

Merged
yinwm merged 17 commits intosipeed:mainfrom
kunalk16:feat-azure-openai-support
Mar 14, 2026
Merged

feat(provider): add support for azure openai provider#1422
yinwm merged 17 commits intosipeed:mainfrom
kunalk16:feat-azure-openai-support

Conversation

@kunalk16
Copy link
Contributor

@kunalk16 kunalk16 commented Mar 12, 2026

📝 Description

Adds support for LLM calls to Azure OpenAI provider so that users can consume LLM models from Azure subscriptions

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

🔗 Related Issue

Closes #1424

📚 Technical Context (Skip for Docs)

  • Reference URL:
  • Reasoning:

🧪 Test Environment

  • Hardware: Azure VM
  • OS: Ubuntu 24.04
  • Model/Provider: gpt-5.2-chat from Azure OpenAI
  • Channels: None

📸 Evidence (Optional)

Screenshots image image

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly.

@CLAassistant
Copy link

CLAassistant commented Mar 12, 2026

CLA assistant check
All committers have signed the CLA.

@sipeed-bot sipeed-bot bot added type: enhancement New feature or request domain: provider go Pull requests that update go code labels Mar 12, 2026
@kunalk16 kunalk16 marked this pull request as ready for review March 12, 2026 10:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a first-class Azure OpenAI provider implementation so PicoClaw can make LLM chat completion calls against Azure OpenAI deployments, while deduplicating shared OpenAI-compatible utilities.

Changes:

  • Introduce pkg/providers/azure provider with Azure-specific URL construction, api-key auth, and max_completion_tokens handling.
  • Extract shared OpenAI-compatible helpers into pkg/providers/common and refactor openai_compat to use them.
  • Wire the provider into the factory/config + update example configs and README provider tables.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/providers/openai_compat/provider.go Refactors OpenAI-compat provider to use new shared common helpers.
pkg/providers/openai_compat/provider_test.go Updates serialization tests to use common.SerializeMessages.
pkg/providers/factory_provider.go Adds azure / azure-openai protocol support and instantiates Azure provider.
pkg/providers/factory_provider_test.go Adds protocol parsing + factory tests for Azure config cases.
pkg/providers/common/common.go New shared utilities: HTTP client creation, message serialization, response/error parsing, numeric helpers.
pkg/providers/common/common_test.go Unit tests for the new shared provider utilities.
pkg/providers/azure/provider.go New Azure OpenAI provider implementation.
pkg/providers/azure/provider_test.go Tests for Azure URL/auth/body behaviors and timeout options.
pkg/config/defaults.go Adds an Azure model entry to the default config template.
config/config.example.json Adds an Azure model example configuration.
README.md Documents azure as a supported provider and adds it to the provider table.
README.zh.md / README.vi.md / README.pt-br.md / README.ja.md / README.fr.md Adds Azure OpenAI entry to localized provider tables.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@kunalk16
Copy link
Contributor Author

@wj-xiao / @lxowalle / @imguoguo Would really appreciate if you could could review this PR as it is getting merge conflicts. :)

@kunalk16
Copy link
Contributor Author

kunalk16 commented Mar 14, 2026

@yinwm / @wj-xiao / @lxowalle / @imguoguo / @alexhoshina Would really appreciate if you could could review this PR. Testing is complete, all PR review comments addressed.

@kunalk16
Copy link
Contributor Author

@alexhoshina I have fixed the linting issues, please could you re-trigger the CI workflow?

xuwei-xy pushed a commit to xuwei-xy/picoclaw that referenced this pull request Mar 14, 2026
Copy link
Collaborator

@yinwm yinwm left a comment

Choose a reason for hiding this comment

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

Code Review: Azure OpenAI Provider Support

Overall

The implementation is well-structured with good separation of concerns. The extraction of common utilities into pkg/providers/common is a solid approach for code reuse.


Findings

1. API Version Hardcoded (provider.go:25)

azureAPIVersion = "2024-10-21"

The API version is hardcoded. Consider documenting the upgrade process or making it configurable.

2. Deployment Name Validation (provider.go:89)

While url.JoinPath provides protection against path traversal, there's no validation on the deployment name itself. Users could pass invalid characters that would cause the request to fail.

Suggestion: Add validation to ensure deployment names only contain allowed characters (alphanumeric, hyphen, underscore).

3. Redundant Empty Check (provider.go:84-86)

The apiBase == "" check in Chat() is redundant since factory_provider.go already validates this. However, it doesn't hurt as a safety measure for direct Provider usage.

4. Error Handling

Consider handling Azure-specific error codes (429 rate limiting, 503 unavailable) for better user experience, though the current generic handling works.

5. Documentation: config.example.json

The example could include the proxy field since many users need it:

{
  "model_name": "azure-gpt5",
  "model": "azure/my-gpt5-deployment",
  "api_key": "your-azure-api-key",
  "api_base": "https://your-resource.openai.azure.com",
  "proxy": ""  // optional
}

6. defaults.go Default Value

APIBase: "https://your-resource.openai.azure.com",

This default is not a valid URL. Consider leaving it empty or using a clearer placeholder like https://<your-resource>.openai.azure.com.


Summary

Category Status
Functionality ✅ Complete
Code Quality ✅ Clean and secure
Security ✅ Path injection protection in place
Maintainability ✅ Good common abstraction
Documentation ⚠️ Minor improvements needed

Overall: Approve - Ready to merge with minor documentation suggestions above.

@yinwm yinwm merged commit 5fb4b3b into sipeed:main Mar 14, 2026
1 check passed
@kunalk16 kunalk16 deleted the feat-azure-openai-support branch March 14, 2026 14:55
Zepan added a commit that referenced this pull request Mar 15, 2026
dj-oyu pushed a commit to dj-oyu/picoclaw that referenced this pull request Mar 16, 2026
* Add support for azure openai provider

* Add checks for deployment model name

* Apply suggestion from @Copilot

Co-authored-by: Copilot <[email protected]>

* Addressing @Copilot suggestion to remove the init() function which seemed redundant

* Fix readme

* Fix linting checks

---------

Co-authored-by: Copilot <[email protected]>
dj-oyu pushed a commit to dj-oyu/picoclaw that referenced this pull request Mar 16, 2026
@Orgmar
Copy link
Contributor

Orgmar commented Mar 16, 2026

@kunalk16 Great addition bringing Azure OpenAI provider support to PicoClaw. Users with Azure subscriptions will appreciate being able to use their deployed models directly. Clean implementation with proper test coverage.

We have a PicoClaw Dev Group on Discord for contributors to connect and collaborate. Interested? Send an email to [email protected] with the subject [Join PicoClaw Dev Group] + your GitHub account and we'll send you the invite link!

neotty pushed a commit to neotty/picoclaw that referenced this pull request Mar 17, 2026
* Add support for azure openai provider

* Add checks for deployment model name

* Apply suggestion from @Copilot

Co-authored-by: Copilot <[email protected]>

* Addressing @Copilot suggestion to remove the init() function which seemed redundant

* Fix readme

* Fix linting checks

---------

Co-authored-by: Copilot <[email protected]>
alexhoshina pushed a commit to alexhoshina/picoclaw that referenced this pull request Mar 17, 2026
* Add support for azure openai provider

* Add checks for deployment model name

* Apply suggestion from @Copilot

Co-authored-by: Copilot <[email protected]>

* Addressing @Copilot suggestion to remove the init() function which seemed redundant

* Fix readme

* Fix linting checks

---------

Co-authored-by: Copilot <[email protected]>
j0904 pushed a commit to j0904/picoclaw that referenced this pull request Mar 22, 2026
* Add support for azure openai provider

* Add checks for deployment model name

* Apply suggestion from @Copilot

Co-authored-by: Copilot <[email protected]>

* Addressing @Copilot suggestion to remove the init() function which seemed redundant

* Fix readme

* Fix linting checks

---------

Co-authored-by: Copilot <[email protected]>
j0904 pushed a commit to j0904/picoclaw that referenced this pull request Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: provider go Pull requests that update go code type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add support for Azure OpenAI provider

5 participants