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 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-imagetask, so the endpoint should be:
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.
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.
Send the request:
And you will get a response in unified response schema. Now you have made your first API call. Happy intergrating!