File tree Expand file tree Collapse file tree 6 files changed +103
-1
lines changed Expand file tree Collapse file tree 6 files changed +103
-1
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ export const FEATHERLESS_AI: string = 'featherless-ai';
102102export const KRUTRIM : string = 'krutrim' ;
103103export const QDRANT : string = 'qdrant' ;
104104export const THREE_ZERO_TWO_AI : string = '302ai' ;
105+ export const MESHY : string = 'meshy' ;
105106
106107export const VALID_PROVIDERS = [
107108 ANTHROPIC ,
@@ -167,6 +168,7 @@ export const VALID_PROVIDERS = [
167168 KRUTRIM ,
168169 QDRANT ,
169170 THREE_ZERO_TWO_AI ,
171+ MESHY ,
170172] ;
171173
172174export const CONTENT_TYPES = {
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ import HyperbolicConfig from './hyperbolic';
6363import { FeatherlessAIConfig } from './featherless-ai' ;
6464import KrutrimConfig from './krutrim' ;
6565import AI302Config from './302ai' ;
66+ import MeshyConfig from './meshy' ;
6667
6768const Providers : { [ key : string ] : ProviderConfigs } = {
6869 openai : OpenAIConfig ,
@@ -126,6 +127,7 @@ const Providers: { [key: string]: ProviderConfigs } = {
126127 'featherless-ai' : FeatherlessAIConfig ,
127128 krutrim : KrutrimConfig ,
128129 '302ai' : AI302Config ,
130+ meshy : MeshyConfig ,
129131} ;
130132
131133export default Providers ;
Original file line number Diff line number Diff line change 1+ import { ProviderAPIConfig } from '../types' ;
2+
3+ const MeshyAPIConfig : ProviderAPIConfig = {
4+ getBaseURL : ( { gatewayRequestURL } ) => {
5+ const version = gatewayRequestURL . includes ( 'text-to-3d' ) ? 'v2' : 'v1' ;
6+ return `https://api.meshy.ai/openapi/${ version } ` ;
7+ } ,
8+ headers : ( { providerOptions } ) => {
9+ return {
10+ Authorization : `Bearer ${ providerOptions . apiKey } ` ,
11+ 'Content-Type' : 'application/json' ,
12+ } ;
13+ } ,
14+ getEndpoint : ( { fn, gatewayRequestURL } ) => {
15+ const basePath = gatewayRequestURL . split ( '/v1' ) ?. [ 1 ] ;
16+
17+ switch ( fn ) {
18+ case 'modelGenerate' :
19+ return '/text-to-3d' ;
20+ default :
21+ return basePath || '' ;
22+ }
23+ } ,
24+ } ;
25+
26+ export default MeshyAPIConfig ;
Original file line number Diff line number Diff line change 1+ import { ProviderConfigs } from '../types' ;
2+ import MeshyAPIConfig from './api' ;
3+ import {
4+ MeshyModelGenerateConfig ,
5+ MeshyModelGenerateResponseTransform ,
6+ } from './modelGenerate' ;
7+
8+ const MeshyConfig : ProviderConfigs = {
9+ modelGenerate : MeshyModelGenerateConfig ,
10+ api : MeshyAPIConfig ,
11+ responseTransforms : {
12+ modelGenerate : MeshyModelGenerateResponseTransform ,
13+ } ,
14+ } ;
15+
16+ export default MeshyConfig ;
Original file line number Diff line number Diff line change 1+ import { MESHY } from '../../globals' ;
2+ import { ErrorResponse , ProviderConfig } from '../types' ;
3+ import { generateInvalidProviderResponseError } from '../utils' ;
4+
5+ export const MeshyModelGenerateConfig : ProviderConfig = {
6+ prompt : {
7+ param : 'prompt' ,
8+ required : true ,
9+ } ,
10+ negative_prompt : {
11+ param : 'negative_prompt' ,
12+ } ,
13+ art_style : {
14+ param : 'art_style' ,
15+ } ,
16+ mode : {
17+ param : 'mode' ,
18+ default : 'preview' ,
19+ } ,
20+ seed : {
21+ param : 'seed' ,
22+ } ,
23+ } ;
24+
25+ interface MeshyModelGenerateResponse {
26+ result : string ;
27+ id ?: string ;
28+ status ?: string ;
29+ created_at ?: string ;
30+ expires_at ?: string ;
31+ }
32+
33+ export const MeshyModelGenerateResponseTransform : (
34+ response : MeshyModelGenerateResponse | ErrorResponse ,
35+ responseStatus : number
36+ ) => MeshyModelGenerateResponse | ErrorResponse = (
37+ response ,
38+ responseStatus
39+ ) => {
40+ if ( responseStatus !== 200 ) {
41+ return generateInvalidProviderResponseError ( response , MESHY ) ;
42+ }
43+
44+ if ( 'result' in response ) {
45+ return {
46+ result : response . result ,
47+ id : response . id ,
48+ status : response . status ,
49+ created_at : response . created_at ,
50+ expires_at : response . expires_at ,
51+ } ;
52+ }
53+
54+ return generateInvalidProviderResponseError ( response , MESHY ) ;
55+ } ;
Original file line number Diff line number Diff line change @@ -105,7 +105,8 @@ export type endpointStrings =
105105 | 'getModelResponse'
106106 | 'deleteModelResponse'
107107 | 'listResponseInputItems'
108- | 'messages' ;
108+ | 'messages'
109+ | 'modelGenerate' ;
109110
110111/**
111112 * A collection of API configurations for multiple AI providers.
You can’t perform that action at this time.
0 commit comments