Skip to content

feat(llms): add NEAR AI Cloud provider#5904

Open
PierreLeGuen wants to merge 1 commit into
crewAIInc:mainfrom
PierreLeGuen:feat/nearai-provider
Open

feat(llms): add NEAR AI Cloud provider#5904
PierreLeGuen wants to merge 1 commit into
crewAIInc:mainfrom
PierreLeGuen:feat/nearai-provider

Conversation

@PierreLeGuen
Copy link
Copy Markdown

@PierreLeGuen PierreLeGuen commented May 22, 2026

Summary

Adds NEAR AI Cloud as a native OpenAI-compatible LLM provider. It can be used with the nearai/ model prefix or by passing provider="nearai".

Implementation notes

  • Registers nearai with https://cloud-api.near.ai/v1, NEARAI_API_KEY, and optional NEARAI_BASE_URL.
  • Reuses the existing OpenAICompatibleCompletion path instead of adding a separate provider class.
  • Handles NEAR AI Cloud compatibility by sending max_tokens instead of max_completion_tokens, dropping unsupported store and reasoning_effort parameters, and omitting strict tool schema mode.

Testing

  • uv run pytest lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py -q
  • uv run ruff check lib/crewai/src/crewai/llm.py lib/crewai/src/crewai/llms/providers/openai_compatible/completion.py lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py
  • uv run ruff format --check lib/crewai/src/crewai/llm.py lib/crewai/src/crewai/llms/providers/openai_compatible/completion.py lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py
  • uv run mypy lib/crewai/src/crewai/llm.py lib/crewai/src/crewai/llms/providers/openai_compatible/completion.py

I could not run a live NEAR AI Cloud smoke test because NEARAI_API_KEY was not set locally.

Summary by CodeRabbit

  • New Features
    • NEAR AI Cloud is now available as a supported provider option
    • Automatic parameter handling and compatibility management for NEAR AI requests
    • Configurable base URL via environment variables for NEAR AI Cloud integration

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d4f06180-aa21-4aa9-8a3c-ec48cc352a49

📥 Commits

Reviewing files that changed from the base of the PR and between 179c20b and c08b974.

📒 Files selected for processing (3)
  • lib/crewai/src/crewai/llm.py
  • lib/crewai/src/crewai/llms/providers/openai_compatible/completion.py
  • lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py

📝 Walkthrough

Walkthrough

This PR integrates NEAR AI Cloud as a native OpenAI-compatible provider. The LLM router recognizes nearai provider names, the provider layer defines capability flags and parameter compatibility rules, request preparation applies NEAR-specific transformations, and comprehensive tests validate routing, parameter handling, and environment configuration.

Changes

NEAR AI Cloud Provider Integration

Layer / File(s) Summary
LLM routing and provider recognition
lib/crewai/src/crewai/llm.py
LLM routing adds nearai to SUPPORTED_NATIVE_PROVIDERS, maps nearai/<model> prefixes to the native provider path, validates provider patterns, and classifies it as OpenAI-compatible for native completion class selection.
Provider configuration schema and NEAR registry
lib/crewai/src/crewai/llms/providers/openai_compatible/completion.py
ProviderConfig gains capability flags (use_max_tokens_for_completion_tokens, supports_reasoning_effort, supports_strict_tool_schema) and an unsupported_params list. OPENAI_COMPATIBLE_PROVIDERS registry entry for nearai specifies base URL, API key env vars, and NEAR-specific compatibility settings.
Request and tool parameter preparation overrides
lib/crewai/src/crewai/llms/providers/openai_compatible/completion.py
OpenAICompatibleCompletion implements provider-config-driven request preparation: remapping max_completion_tokens to max_tokens when configured, conditionally stripping unsupported parameters, and removing strict from tool schemas when unsupported.
Provider routing, configuration, and environment override tests
lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py
Tests verify ProviderConfig defaults, NEAR provider registry entry, correct routing for both nearai/<model> and explicit provider selection, and NEARAI_BASE_URL env override.
Request parameter normalization and tool schema handling tests
lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py
Tests validate NEAR-specific parameter remapping, filtering of unsupported OpenAI parameters, and removal of strict from tool function schemas.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A new provider hops into the warren,
NEAR AI Cloud joins the native fray,
With tokens remapped and schemas tamed,
Parameter filters smooth the way,
Tests verify each hop and bound! 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding NEAR AI Cloud as a new LLM provider to the system.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@PierreLeGuen
Copy link
Copy Markdown
Author

I do not have permission to apply repository labels from this fork. This PR should have the llm-generated label per the contribution guide.

@PierreLeGuen PierreLeGuen marked this pull request as ready for review May 22, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant