Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions components/apipie_ai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Overview

[APIpie.ai](https://apipie.ai) connects developers with open-source and commercial AI models via a unified API. With zero infrastructure setup, you can send requests to popular models, switch providers instantly, and explore a growing catalog of AI models—all through one endpoint. Here's an overview of the services offered by [APIpie's API](https://apipie.ai):

- **Model Discovery**: List and explore available LLM models, image models, voice models, and voices from various providers as seen on the [APIpie Dashboard](https://apipie.ai/dashboard)
- **Chat Completions**: Send messages to any supported model and receive AI-generated responses
- **Image Generation**: Create images using AI image generation models
- **Text-to-Speech**: Convert text to speech using various voice models and voices

Use Python or Node.js code to make fully authenticated API requests with your APIpie account, enabling you to prototype, test, or integrate AI-generated content including text, images, and speech into apps, emails, alerts, dashboards, and more.

# Example Use Cases

The [APIpie API](https://apipie.ai) can be leveraged in a wide range of business contexts to drive efficiency, enhance customer experiences, and innovate product offerings through unified access to multiple AI models. Here are some specific business use cases for utilizing the APIpie API:

## **Customer Support Automation**

Significantly reduce response times and free up human agents to tackle more complex issues by automating customer support ticket responses. Use the List Models actions to dynamically select the most appropriate AI model based on ticket complexity or language requirements, then leverage Chat Completions to generate contextual, helpful responses that can be reviewed before sending to customers.

## **Content Creation and Management**

Utilize AI to generate high-quality content for blogs, articles, product descriptions, and marketing material. Create workflows that automatically test different models using the same prompt to compare writing styles, then select the best output for your brand voice. Generate accompanying images and convert text to speech for multimedia content creation. APIpie's unified interface lets you experiment with various open-source and commercial models without managing multiple API integrations.

## **Creative Asset Generation**

Generate visual content and audio assets for marketing campaigns, presentations, and social media. Use image generation models to create custom graphics, illustrations, and visual content that align with your brand. Convert written content to speech using different voice models to create podcasts, audiobooks, or accessibility features for your applications.

## **Multi-Model AI Experimentation Framework**

Build intelligent systems that automatically compare AI model performance across different use cases and modalities. Set up workflows that test text generation, image creation, and voice synthesis across multiple models simultaneously, collect responses in databases, and analyze quality, cost, and latency differences. This enables data-driven decisions about which AI models work best for specific business scenarios, while maintaining the flexibility to switch providers as new models become available.

# Getting Started

First, sign up for an APIpie account, then in a new workflow step open the APIpie app and select one of the available actions:

- **Retrieve Available Image Models**: Fetch the current catalog of available language models
- **Retrieve Available LLM Models**: Fetch the current catalog of available image generation models
- **Retrieve Available TTS Models**: Fetch the current catalog of available voice models
- **Retrieve Available TTS Voices**: Fetch the available voices for text-to-speech
- **Send Chat Completion Request**: Send messages to any supported language model and receive responses
- **Create Image**: Generate images using AI image generation models
- **Convert Text to Speech (TTS)**: Convert text to speech using various voice models and voices

Then connect your APIpie account to Pipedream. Visit [APIpie.ai](https://apipie.ai) and navigate to your profile to generate your [API key.](https://apipie.ai/profile/api-keys)

Copy your API key and paste it into Pipedream when prompted. Now you're all set to use pre-built actions like `Chat`, `Create Image`, `Create Text to Speech`, or any of the list actions, or use your APIpie API key directly in Node.js or Python code to access the unified AI model interface.
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import fs from "fs";
import apipieAi from "../../apipie_ai.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "apipie_ai-convert-text-to-speech",
name: "Convert Text to Speech (TTS)",
description: "Generates audio from the input text. [See the documentation](https://apipie.ai/docs/Features/Voices)",
version: "0.0.1",
type: "action",
props: {
apipieAi,
model: {
propDefinition: [
apipieAi,
"ttsModelId",
],
reloadProps: true,
},
input: {
propDefinition: [
apipieAi,
"input",
],
},
responseFormat: {
propDefinition: [
apipieAi,
"audioResponseFormat",
],
},
speed: {
propDefinition: [
apipieAi,
"speed",
],
},
outputFile: {
type: "string",
label: "Output Filename",
description: "The filename of the output audio file that will be written to the `/tmp` folder, e.g. `/tmp/myFile.mp3`",
},
},
async additionalProps() {
try {
const props = {};
if (this.model) {
// Parse the model JSON to get id and route
const modelData = JSON.parse(this.model);
const { route } = modelData;

// Get all voices and filter by the model route
const { data } = await this.apipieAi.listVoices();
const filteredVoices = data.filter(voice => voice.model === route);

const uniqueVoices = new Map();
filteredVoices.forEach(({ voice_id, name }) => {
if (!uniqueVoices.has(voice_id)) {
uniqueVoices.set(voice_id, name);
}
});

props.voice = {
type: "string",
label: "Voice",
description: "The voice to use when generating the audio.",
options: Array.from(uniqueVoices.entries())
.map(([value, name]) => ({
label: name,
value,
}))
.sort((a, b) => a.label.localeCompare(b.label)),
};
}
return props;
} catch (e) {
$.export("Error fetching voices", e);
throw new ConfigurationError(e.message || "Failed to fetch voices");
}
},
async run({ $ }) {
// Parse the model JSON to get the actual model id for the API call
try {
const modelData = JSON.parse(this.model);
const { id: modelId } = modelData;
const response = await this.apipieAi.createSpeech({
$,
data: {
model: modelId,
input: this.input,
voice: this.voice,
response_format: this.responseFormat,
speed: this.speed,
},
responseType: "arraybuffer",
});

if (response.error) {
$.export("Error creating audio", response.error);
throw new ConfigurationError(response.error.message || "Failed to create audio");
}
const outputFilePath = this.outputFile.includes("tmp/")
? this.outputFile
: `/tmp/${this.outputFile}`;

try {
await fs.promises.writeFile(outputFilePath, Buffer.from(response));
} catch (e) {
$.export("Error saving audio file", e);
throw new ConfigurationError(e.message || "Failed to save audio file");
}
$.export("$summary", "Generated audio successfully");
return {
outputFilePath,
response,
};
} catch (e) {
$.export("Error creating audio", e);
throw new ConfigurationError(e.message || "Failed to create audio");
}
},
};
84 changes: 84 additions & 0 deletions components/apipie_ai/actions/create-image/create-image.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import apipieAi from "../../apipie_ai.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
name: "Create Image",
version: "0.0.1",
key: "apipie_ai-create-image",
description: "Creates an image given a prompt returning a URL to the image. [See the documentation](https://apipie.ai/docs/Features/Images)",
type: "action",
props: {
apipieAi,
model: {
propDefinition: [
apipieAi,
"imageModelId",
],
},
prompt: {
propDefinition: [
apipieAi,
"prompt",
],
},
responseFormat: {
propDefinition: [
apipieAi,
"imageResponseFormat",
],
},
size: {
propDefinition: [
apipieAi,
"size",
],
},
n: {
propDefinition: [
apipieAi,
"n",
],
},
quality: {
propDefinition: [
apipieAi,
"quality",
],
},
style: {
propDefinition: [
apipieAi,
"style",
],
},
},
async run({ $ }) {
try {
const response = await this.apipieAi.createImage({
$,
data: {
prompt: this.prompt,
n: this.n,
size: this.size,
...(this.responseFormat && { response_format: this.responseFormat }),
model: this.model,
quality: this.quality,
style: this.style,
},
});
if (response.error) {
$.export("Error creating Image", response.error);
throw new ConfigurationError(response.error.message || "Failed to create Image");
}
if (response.data.length) {
$.export("$summary", `Successfully created ${response.data.length} image${response.data.length === 1
? ""
: "s"}`);
}
return response;
} catch (e) {
$.export("Error creating Image", e);
throw new ConfigurationError(e.message || "Failed to create Image");
}
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import apipieAi from "../../apipie_ai.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "apipie_ai-retrieve-available-image-models",
name: "Retrieve Available Image Models",
version: "0.0.1",
description: "Returns a list of Image models available through the API. [See the dashboard](https://apipie.ai/dashboard)",
type: "action",
props: {
apipieAi,
},
async run({ $ }) {
try {
const response = await this.apipieAi.listImageModels({
$,
});
$.export("$summary", `Successfully retrieved ${response.data.length} available Image model(s)!`);
return response;
} catch (e) {
$.export("Error fetching Image Models", e);
throw new ConfigurationError(e.message || "Failed to fetch Image Models");
}
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import apipieAi from "../../apipie_ai.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "apipie_ai-retrieve-available-llm-models",
name: "Retrieve Available LLM Models",
version: "0.0.1",
description: "Returns a list of LLM models available through the API. [See the dashboard](https://apipie.ai/dashboard)",
type: "action",
props: {
apipieAi,
},
async run({ $ }) {
try {
const response = await this.apipieAi.listLlmModels({
$,
});
$.export("$summary", `Successfully retrieved ${response.data.length} available LLM model(s)!`);
return response;
} catch (e) {
$.export("Error fetching LLM Models", e);
throw new ConfigurationError(e.message || "Failed to fetch LLM Models");
}
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import apipieAi from "../../apipie_ai.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "apipie_ai-retrieve-available-tts-models",
name: "Retrieve Available TTS Models",
version: "0.0.1",
description: "Returns a list of TTS models available through the API. [See the dashboard](https://apipie.ai/dashboard)",
type: "action",
props: {
apipieAi,
},
async run({ $ }) {
try {
const response = await this.apipieAi.listTtsModels({
$,
});
$.export("$summary", `Successfully retrieved ${response.data.length} available TTS model(s)!`);
return response;
} catch (e) {
$.export("Error fetching TTS Models", e);
throw new ConfigurationError(e.message || "Failed to fetch TTS models");
}
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import apipieAi from "../../apipie_ai.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "apipie_ai-retrieve-available-tts-voices",
name: "Retrieve Available TTS Voices",
version: "0.0.1",
description: "Returns a list of TTS Voices available through the API. [See the dashboard](https://apipie.ai/dashboard)",
type: "action",
props: {
apipieAi,
},
async run({ $ }) {
try {
const response = await this.apipieAi.listVoices({
$,
});
$.export("$summary", `Successfully retrieved ${response.data.length} available TTS Voices!`);
return response;
} catch (e) {
$.export("Error fetching Voices", e);
throw new ConfigurationError(e.message || "Failed to fetch Voices");
}
},
};
Loading