feat(core): add NEAR AI model provider#1291
Conversation
🦋 Changeset detectedLatest commit: 9ddf824 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds NEAR AI Cloud ( ChangesNEAR AI Cloud Provider Integration
Sequence Diagram — model resolution and request flow: sequenceDiagram
participant Caller
participant Registry as ModelProviderRegistry
participant Adapter as OpenAICompatibleAdapter
participant NearAI as NEAR_AI_Cloud
Caller->>Registry: request resolveLanguageModel("nearai/<model>")
Registry->>Adapter: createOpenAICompatible(config with NEARAI_API_KEY, NEARAI_BASE_URL?)
Adapter->>Adapter: apply transformRequestBody(sanitizeNearAIRequestBody)
Caller->>Adapter: send inference request (messages, tools, response_format)
Adapter->>Adapter: transformRequestBody -> sanitizedRequest
Adapter->>NearAI: HTTP call with sanitizedRequest
NearAI-->>Adapter: response
Adapter-->>Caller: normalized response
🎯 3 (Moderate) | ⏱️ ~25 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/src/registries/model-provider-registry-nearai.spec.ts`:
- Around line 5-7: The current vi.mock of "`@voltagent/internal`" replaces
safeStringify with plain JSON.stringify which breaks expected safeStringify
behavior; update the mock inside the vi.mock call to provide a safeStringify
implementation that matches the real utility (handles circular references and
non-JSON values) — e.g., implement a serializer that tracks a seen Set to avoid
circular recursion and returns stable string representations for
functions/undefined/BigInt instead of throwing, or import and re-export the real
safeStringify implementation if available; ensure the mock exports the symbol
safeStringify used by the tests (the vi.mock call and the safeStringify symbol).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: da327098-4811-42e4-86fd-d41bce80963c
📒 Files selected for processing (10)
.changeset/nearai-provider.mdpackages/core/src/registries/embedding-model-router-types.generated.tspackages/core/src/registries/model-provider-registry-nearai.spec.tspackages/core/src/registries/model-provider-registry.generated.tspackages/core/src/registries/model-provider-registry.tspackages/core/src/registries/model-provider-types.generated.tswebsite/docs/getting-started/providers-models.mdwebsite/models-docs/overview.mdwebsite/models-docs/providers/nearai.mdwebsite/models-docs/providers/overview.md
PR Checklist
What is the current behavior?
NEAR AI Cloud is not included in VoltAgent's bundled model router registry, so users need to configure it manually as an OpenAI-compatible provider.
What is the new behavior?
Adds
nearaias an OpenAI-compatible model router provider withNEARAI_API_KEYand the default base URLhttps://cloud-api.near.ai/v1. The change also adds NEAR model and embedding type entries, provider docs, and a focused registry test.For the NEAR route, the OpenAI-compatible request body is adjusted to avoid unsupported strict/advanced fields while keeping the existing adapter path.
Notes for reviewers
The model list follows the current
nearaientry from the models.dev registry source used by VoltAgent's bundled provider snapshot. I did not run a live NEAR request locally.Testing:
pnpm --filter @voltagent/internal buildpnpm --filter @voltagent/core exec vitest run src/registries/model-provider-registry-nearai.spec.ts src/registries/model-provider-registry-minimax.spec.tspnpm --filter @voltagent/core typecheckpnpm biome check packages/core/src/registries/model-provider-registry.ts packages/core/src/registries/model-provider-registry-nearai.spec.ts packages/core/src/registries/model-provider-registry.generated.ts packages/core/src/registries/model-provider-types.generated.ts packages/core/src/registries/embedding-model-router-types.generated.tspnpm exec prettier --check website/models-docs/providers/nearai.md website/models-docs/providers/overview.md website/models-docs/overview.md website/docs/getting-started/providers-models.md .changeset/nearai-provider.mdSummary by CodeRabbit
New Features
Configuration
Documentation