Skip to content

Conversation

dd-eg-user
Copy link
Contributor

Description

Adds comprehensive Tripo3D provider integration to the Portkey AI Gateway, enabling users to route 3D model generation requests through Portkey to Tripo3D's API. This implementation provides full support for all Tripo3D endpoints
including task creation, status polling, file uploads, and account management.

Motivation

Tripo3D is a leading 3D generation platform that converts text prompts and images into high-quality 3D models. Adding Tripo3D as a provider expands Portkey's capabilities into the 3D generation space, allowing users to leverage Portkey's
reliability features (retries, fallbacks, load balancing) with Tripo3D's powerful 3D AI models.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

How Has This Been Tested?

  • Unit Tests
  • Integration Tests
  • Manual Testing

Screenshots (if applicable)

Checklist

  • My code follows the style guidelines of this project
  • [ x I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Related Issues

Copy link
Contributor

matter-code-review bot commented Aug 21, 2025

Code Quality new feature

Description

Summary By MatterAI MatterAI logo

🔄 What Changed

The getEndpoint function within the Tripo3DAPIConfig in src/providers/tripo3d/api.ts was modified. It now accepts a fn parameter and consistently returns an empty string, removing the previous logic that extracted a path segment from gatewayRequestURL. This change is part of a broader integration to add comprehensive Tripo3D provider support to the Portkey AI Gateway.

🔍 Impact of the Change

This change simplifies the endpoint determination for the Tripo3D provider, aligning with the new integration strategy. By returning an empty string, it suggests that the full API path for Tripo3D endpoints (such as task creation, status polling, and file uploads) is now handled by the base URL configuration or derived from the fn parameter elsewhere in the gateway's logic, rather than dynamic path extraction within this specific configuration. This provides a consistent mechanism for routing requests to Tripo3D's API.

📁 Total Files Changed

  • src/providers/tripo3d/api.ts: Modified the getEndpoint function to return an empty string, simplifying endpoint path determination.

🧪 Test Added

N/A

🔒Security Vulnerabilities

No new direct security vulnerabilities were introduced by this specific change. The apiKey is still used for authorization. The simplification of getEndpoint removes a potential vector for path manipulation if gatewayRequestURL was untrusted, though this was likely not a primary concern given the context.

Motivation

Adds comprehensive Tripo3D provider integration to the Portkey AI Gateway, enabling users to route 3D model generation requests through Portkey to Tripo3D's API. This implementation provides full support for all Tripo3D endpoints including task creation, status polling, file uploads, and account management.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

How Has This Been Tested?

N/A

Screenshots (if applicable)

N/A

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Tip

Quality Recommendations

  1. Add unit and integration tests for the Tripo3D provider to ensure all endpoints (task creation, status polling, file uploads, account management) function correctly through the Portkey AI Gateway.

  2. Clarify and document how the specific Tripo3D API endpoints are determined and routed within the Portkey AI Gateway, given that getEndpoint now consistently returns an empty string. This should explain the role of the fn parameter or other routing mechanisms.

  3. Consider adding comments to the getEndpoint function in src/providers/tripo3d/api.ts to explain why it returns an empty string and how the actual endpoint path is constructed.

Tanka Poem ♫

Path now simplified,
Gateway finds its way with ease,
Tripo3D awaits.
Models bloom in digital space,
New connections, science thrives. ✨

Sequence Diagram

sequenceDiagram
    participant User as User
    participant Gateway as Portkey AI Gateway
    participant Tripo3DConfig as Tripo3DAPIConfig
    participant Tripo3DAPI as Tripo3D API

    User->>+Gateway: Request 3D Model Generation (e.g., POST /v1/tripo3d/tasks)
    Note over Gateway: Process request for Tripo3D provider
    Gateway->>Tripo3DConfig: getEndpoint({ fn: "task_creation" })
    Note over Tripo3DConfig: Returns ''
    Tripo3DConfig-->>-Gateway: '' (empty string)
    Note over Gateway: Construct full Tripo3D API URL using base URL and 'fn'
    Gateway->>+Tripo3DAPI: POST /v1/tasks (with payload)
    Tripo3DAPI-->>-Gateway: 200 OK / Task ID
    Gateway-->>-User: 200 OK / Response
Loading

Copy link
Contributor

@matter-code-review matter-code-review bot left a comment

Choose a reason for hiding this comment

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

Well-structured Tripo3D provider implementation with comprehensive API coverage. Found one type safety issue in getTask.ts that could cause runtime errors.

| 'unknown'
| 'banned'
| 'expired';
input: any;
Copy link
Contributor

Choose a reason for hiding this comment

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

🐛 Bug Fix

Issue: The input field is typed as any, which eliminates type safety and could lead to runtime errors when accessing properties
Fix: Define a proper interface for the input structure based on the task types
Impact: Prevents potential runtime crashes and improves code maintainability

Suggested change
input: any;
input: Record<string, unknown>;

Copy link
Contributor

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@dd-eg-user dd-eg-user changed the title Feat/add tripo3d provider integration: add tripo3d provider Aug 21, 2025
@roh26it
Copy link
Collaborator

roh26it commented Aug 22, 2025

@dd-eg-user as discussed, would you be able to add credits_used to the response object to enable pricing configs?

@dd-eg-user
Copy link
Contributor Author

@dd-eg-user as discussed, would you be able to add credits_used to the response object to enable pricing configs?

Happy to take a look! Could you point me to an example where this is done today? https://github.com/search?q=repo%3APortkey-AI%2Fgateway+credits_used&type=code yields no results.

Tripo3D doesn't really have a notion of credits_used especially given the async nature of the API where tasks are created and then status checked later by clients. It also isn't really feasible to do something like:

T0 - take snapshot of balance
T1 - do something
T2 - take snapshot of balance, compute difference

because 1) you probably want cost per task and there could be multiple tasks running simultaneously affecting balance 2) multiple requests per API key in between T0 and T2 would also alter balance making it incorrect.

We could try to embed the pricing table into this provider, but it can get out of date quickly and we also have to put in logic as to what is meant by things like did this call result in "post stylization".

https://platform.tripo3d.ai/docs/schema and https://platform.tripo3d.ai/docs/billing

Copy link
Contributor

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

Copy link
Collaborator

@narengogi narengogi left a comment

Choose a reason for hiding this comment

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

Hey @dd-eg-user
since we do not have a unified signature for these routes,
I'd suggest only keeping the api.ts file and removing the transforms in src/providers/tripo3d
this would allow gateway to act as auth layer and allow passthrough proxy requests

so you index file would simply become

import { ProviderConfigs } from '../types';
import Tripo3DAPIConfig from './api';

const Tripo3DConfig: ProviderConfigs = {
  api: Tripo3DAPIConfig,
};

export default Tripo3DConfig;

you can remove the changes in src/providers/types.ts as well
so finally the only required files are

src/providers/tripo3d/api.ts, src/providers/tripo3d/index.ts, globals.ts

@dd-eg-user
Copy link
Contributor Author

Hey @dd-eg-user since we do not have a unified signature for these routes, I'd suggest only keeping the api.ts file and removing the transforms in src/providers/tripo3d this would allow gateway to act as auth layer and allow passthrough proxy requests

so you index file would simply become

import { ProviderConfigs } from '../types';
import Tripo3DAPIConfig from './api';

const Tripo3DConfig: ProviderConfigs = {
  api: Tripo3DAPIConfig,
};

export default Tripo3DConfig;

you can remove the changes in src/providers/types.ts as well so finally the only required files are

src/providers/tripo3d/api.ts, src/providers/tripo3d/index.ts, globals.ts

Thanks for the review. How does this comment and #1296 (comment) work together? The pricing is only relevant on one endpoint. If we remove those endpoints and acts as a passthrough, not sure how we'd add pricing information to the response.

Copy link
Contributor

@matter-code-review matter-code-review bot left a comment

Choose a reason for hiding this comment

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

Clean refactor to use gatewayRequestURL for better path extraction. The implementation correctly handles the /v1 prefix removal.

Comment on lines 8 to 11
getEndpoint: ({ gatewayRequestURL }) => {
// For passthrough proxy, extract path after /v1
return gatewayRequestURL.split('/v1')[1] || '';
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Code Refactor

Issue: The split operation could fail if gatewayRequestURL doesn't contain '/v1', potentially causing runtime errors
Fix: Add validation to ensure the URL contains '/v1' before splitting
Impact: Prevents potential crashes when processing malformed URLs

Suggested change
getEndpoint: ({ gatewayRequestURL }) => {
// For passthrough proxy, extract path after /v1
return gatewayRequestURL.split('/v1')[1] || '';
},
getEndpoint: ({ gatewayRequestURL }) => {
// For passthrough proxy, extract path after /v1
const parts = gatewayRequestURL.split('/v1');
return parts.length > 1 ? parts[1] : '';
},

Copy link
Contributor

Choose a reason for hiding this comment

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

Resolved: Original URL splitting logic completely removed and replaced with empty string return

Copy link
Contributor

Simple refactor replacing complex URL parsing logic with empty string return. Change appears intentional for simplified endpoint handling.

eg-renovate-user and others added 9 commits September 2, 2025 13:44
Add comprehensive Tripo3D provider integration with support for:
- Task creation (text_to_model, image_to_model, etc.)
- Task status polling
- File uploads and STS token management
- Account balance checking

Implements all Tripo3D API endpoints from their OpenAPI schema.
- Changes input field type from 'any' to 'Record<string, any>'
- Adds documentation explaining why this type is used
- Maintains flexibility while providing better type safety
- Addresses feedback about eliminating 'any' usage
- Remove custom transforms and endpoint configs as requested in review
- Keep only api.ts for authentication layer functionality
- Revert endpoint string additions to types.ts
- Delete unnecessary transform files (createTask, getTask, upload, balance, pricing)
- Provider now acts as pure passthrough proxy like Sagemaker
- Change getEndpoint to use providerPath instead of hardcoded fn cases
- Fixes TypeScript errors after removing endpoint strings from types
- Replace providerPath with gatewayRequestURL.split('/v1')[1]
- Matches pattern used by other passthrough providers like Sagemaker
- Fixes TypeScript error in getEndpoint function
- Change from gatewayRequestURL.split('/v1')[1] to empty string return
- Matches pattern used by other simple passthrough providers like Replicate
- Addresses review comment about incorrect getEndpoint implementation
@dd-eg-user dd-eg-user force-pushed the feat/add-tripo3d-provider branch from d1a3373 to 51405a7 Compare September 2, 2025 17:45
Copy link
Contributor

@matter-code-review matter-code-review bot left a comment

Choose a reason for hiding this comment

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

Simple endpoint configuration change looks good. The hardcoded empty string approach is valid for this provider's architecture.

headers: ({ providerOptions }) => {
return { Authorization: `Bearer ${providerOptions.apiKey}` };
},
getEndpoint: ({ fn }) => '',
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Code Refactor

Issue: The getEndpoint function now returns a hardcoded empty string, which may not be intuitive for future maintainers
Fix: Add a comment explaining why an empty string is returned for this provider
Impact: Improves code maintainability and reduces confusion for developers

Suggested change
getEndpoint: ({ fn }) => '',
getEndpoint: ({ fn }) => '', // Tripo3D uses base URL without additional path

@VisargD VisargD merged commit 7a1792c into Portkey-AI:main Sep 3, 2025
1 check passed
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.

5 participants