KawaiiApp commited on
Commit
f1d2bde
1 Parent(s): a9108ee

added docs

Browse files
Files changed (1) hide show
  1. README.md +113 -1
README.md CHANGED
@@ -9,4 +9,116 @@ tags:
9
  - diffusers
10
  inference: true
11
  pipeline_tag: text-to-image
12
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  - diffusers
10
  inference: true
11
  pipeline_tag: text-to-image
12
+ ---
13
+
14
+
15
+ # Inference API Documentation
16
+
17
+ ## Overview
18
+ 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.
19
+
20
+ ## Base URL
21
+ The base URL for the Inference API is: `<hf_endpoint_url>`
22
+
23
+ ## Authentication
24
+ The Inference API requires authentication using a bearer token. Include the token in the `Authorization` header of your requests.
25
+
26
+ ## Request Format
27
+ Send a POST request to the endpoint URL with the following JSON payload:
28
+
29
+ ```json
30
+ {
31
+ "inputs": "<positive_prompt>",
32
+ "negative_prompt": "<negative_prompt>",
33
+ "height": <height>,
34
+ "width": <width>,
35
+ "guidance_scale": <guidance_scale>
36
+ }
37
+ ```
38
+ ## Request Parameters
39
+
40
+ | Parameter | Type | Required | Description |
41
+ |-------------------|----------|----------|----------------------------------------------------|
42
+ | inputs | string | Yes | The positive prompt for the inference. |
43
+ | negative_prompt | string | No | The negative prompt for the inference (optional). |
44
+ | height | integer | Yes | The height of the image. |
45
+ | width | integer | Yes | The width of the image. |
46
+ | guidance_scale | float | Yes | The guidance scale for the inference. |
47
+
48
+ ## Response Format
49
+ The API response will be a JSON object with the following structure:
50
+
51
+ ```json
52
+ {
53
+ "image": "<base64_encoded_image>"
54
+ }
55
+ ```
56
+ ## Response Format
57
+ The API response will be a JSON object with the following structure:
58
+
59
+ | Field | Type | Description |
60
+ |--------|--------|------------------------------------------------|
61
+ | image | string | The base64-encoded image generated by the API. |
62
+
63
+ ## Example Request
64
+
65
+
66
+
67
+
68
+ ### Here's an example request using Python:
69
+
70
+ ```python
71
+
72
+ import requests
73
+
74
+ url = '<hf_endpoint_url>'
75
+ token = '<hf_token>'
76
+
77
+ requestData = {
78
+ 'inputs': 'Positve prompt',
79
+ 'negative_prompt': 'Negative prompt goes here',
80
+ 'height': 512,
81
+ 'width': 512,
82
+ 'guidance_scale': 7.5
83
+ }
84
+
85
+ headers = {
86
+ 'Authorization': 'Bearer ' + token,
87
+ 'Content-Type': 'application/json'
88
+ }
89
+
90
+ response = requests.post(url, json=requestData, headers=headers)
91
+ print(response.json())
92
+ ```
93
+
94
+ ### Here's an example request using JavaScript:
95
+
96
+ ```js
97
+ const endpointURL = '<hf_endpoint_url>';
98
+ const hfToken = '<hf_token>';
99
+
100
+ const requestData = {
101
+
102
+ s: 'Positve prompt',
103
+ negative_prompt: 'Negative prompt goes here',
104
+ height: 512,
105
+ width: 512,
106
+ guidance_scale: 7.5
107
+ };
108
+
109
+ const headers = {
110
+ 'Authorization': `Bearer ${hfToken}`,
111
+ 'Content-Type': 'application/json'
112
+ };
113
+
114
+ fetch(endpointURL, {
115
+ method: 'POST',
116
+ body: JSON.stringify(requestData),
117
+ headers: headers
118
+ })
119
+ .then(response => response.json())
120
+ .then(data => console.log(data))
121
+ .catch(error => console.error(error));
122
+
123
+
124
+ ```