File size: 3,304 Bytes
966bbc8
 
 
 
 
 
 
 
 
 
 
f1d2bde
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8bc2f14
 
f1d2bde
 
 
 
 
 
 
8bc2f14
f1d2bde
 
 
8bc2f14
f1d2bde
 
 
 
 
 
 
 
 
 
 
 
 
 
8bc2f14
f1d2bde
 
8bc2f14
f1d2bde
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8bc2f14
 
f1d2bde
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8bc2f14
 
f1d2bde
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
---
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));


```