Let's make your first API call to access AI functionalities using the service from PiAPI!Generate an API key#
💡
What is API key?
An API key is a secure credential that allows your code to interact with our API. Never share your API key with anyone, as it can be exploited without your knowledge.
1.
Create an account : Go to PiAPI workspace and log in with your github account. 2.
Create an API key: After logged in, navigate to the API key in workspace and generate one.
Set Base URL#
This is the URL to be used for all of our API calls:Make your first API call#
Let's take Flux API for an example.1.
Set URL endpoint: With our Unified API Schema, users could interact with all models and services through just two endpoints: create task
and get task
.
Here we want to create a Flux text-to-image
task, so the endpoint should be: 2.
Set the header: In most cases, you will need an API key for authorization. Remember to replace the YOUR_API_KEY
with your own API key. The headers look like this: 3.
Set the request Body: APIs of Unified API schema share the same request and response format. you will need to specify three main components:
model
: The specific model you wish to interact with. Here we set to Qubico/flux1-schnell
.
task_type
: The type of task. Here we set to txt2img
.
input
: The inputs specific to the task and model.prompt
is required, Let's set to "a bear" for example.{
"model": "flux1-schnell",
"task_type": "txt2img",
"input": {
"prompt": "a bear",
}
}
For the introduction of params needed in request body, refer to the documentation of specific endpoint you want to interact with.
You can check Flux Text to Image endpoint doc about the params above. 4.
And you will get a response in unified response schema. Now you have made your first API call. Happy intergrating! Alternate Domains#
Here are the available domains for all of our API endpoints. we recommend you to experiment with them and change the domains as needed:1.
api.piapi.ai - the primary domain for all API endpoints
Modified at 2025-01-09 07:19:04