KawaiiApp's picture
added new attributes
8bc2f14
---
language:
- en
license: creativeml-openrail-m
tags:
- stable-diffusion
- stable-diffusion-diffusers
- text-to-image
- diffusers
inference: true
pipeline_tag: text-to-image
---
# Inference API Documentation
## Overview
The Inference API allows you to make inference requests to perform image processing tasks using a remote service. This API supports various operations and requires specific input parameters.
## Base URL
The base URL for the Inference API is: `<hf_endpoint_url>`
## Authentication
The Inference API requires authentication using a bearer token. Include the token in the `Authorization` header of your requests.
## Request Format
Send a POST request to the endpoint URL with the following JSON payload:
```json
{
"inputs": "<positive_prompt>",
"negative_prompt": "<negative_prompt>",
"height": <height>,
"width": <width>,
"guidance_scale": <guidance_scale>,
"inference_steps" : <inference_steps>,
}
```
## Request Parameters
| Parameter | Type | Required | Description |
|-------------------|----------|----------|----------------------------------------------------|
| inputs | string | Yes | The positive prompt for the inference. |
| negative_prompt | string | No | The negative prompt for the inference (optional). |
| height | integer | Yes | The height of the image. |
| width | integer | Yes | The width of the image. |
| guidance_scale | float | Yes | The guidance scale for the inference. |
| inference_steps | integer | No | The steps for inference.(25 default) |
## Response Format
The API response will be a JSON object with the following structure:
```json
{
"image": "<base64_encoded_image>"
}
```
## Response Format
The API response will be a JSON object with the following structure:
| Field | Type | Description |
|--------|--------|------------------------------------------------|
| image | string | The base64-encoded image generated by the API. |
## Example Request
### Here's an example request using Python:
```python
import requests
url = '<hf_endpoint_url>'
token = '<hf_token>'
requestData = {
'inputs': 'Positve prompt',
'negative_prompt': 'Negative prompt goes here',
'height': 512,
'width': 512,
'guidance_scale': 7.5,
'inference_steps': 50,
}
headers = {
'Authorization': 'Bearer ' + token,
'Content-Type': 'application/json'
}
response = requests.post(url, json=requestData, headers=headers)
print(response.json())
```
### Here's an example request using JavaScript:
```js
const endpointURL = '<hf_endpoint_url>';
const hfToken = '<hf_token>';
const requestData = {
s: 'Positve prompt',
negative_prompt: 'Negative prompt goes here',
height: 512,
width: 512,
guidance_scale: 7.5,
inference_steps: 50,
};
const headers = {
'Authorization': `Bearer ${hfToken}`,
'Content-Type': 'application/json'
};
fetch(endpointURL, {
method: 'POST',
body: JSON.stringify(requestData),
headers: headers
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
```