Adding and Removing Data
Manage the data in your app.

Inputs

The API is built around a simple idea. You send inputs (images) to the service and it returns predictions. In addition to receiving predictions on inputs, you can also index inputs and their predictions to later search against. You can also index inputs with concepts to later train your own model.
When you add an input to your app, the base workflow of your app runs, computing the outputs from all the models in that workflow and indexes those outputs. Those indexed outputs are what incur the indexing fee monthly, and enable search and training on top of the outputs of the base workflow models.

Add Inputs

You can add inputs one by one or in bulk. If you do send bulk, you are limited to sending 128 inputs at a time.
Important: adding inputs is an asynchronous operation. That means it will process indexing of your inputs through your default workflow in the background, which can take some time. In order to check the status of each input you add, see the section on Get Input by ID to look for status 30000 (INPUT_IMAGE_DOWNLOAD_SUCCESS) status code on each input to know when it's successfully been indexed.

Add an input using a publicly accessible URL

Java
NodeJS
Python
C#
cURL
Javascript (REST)
1
import com.clarifai.grpc.api.*;
2
import com.clarifai.grpc.api.status.*;
3
4
// Insert here the initialization code as outlined on this page:
5
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
6
7
MultiInputResponse postInputsResponse = stub.postInputs(
8
PostInputsRequest.newBuilder().addInputs(
9
Input.newBuilder().setData(
10
Data.newBuilder().setImage(
11
Image.newBuilder()
12
.setUrl("https://samples.clarifai.com/metro-north.jpg")
13
.setAllowDuplicateUrl(true)
14
)
15
)
16
).build()
17
);
18
19
if (postInputsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
20
throw new RuntimeException("Post inputs failed, status: " + postInputsResponse.getStatus());
21
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
stub.PostInputs(
5
{
6
inputs: [{data: {image: {url: "https://samples.clarifai.com/metro-north.jpg", allow_duplicate_url: true}}}]
7
},
8
metadata,
9
(err, response) => {
10
if (err) {
11
throw new Error(err);
12
}
13
14
if (response.status.code !== 10000) {
15
throw new Error("Post inputs failed, status: " + response.status.description);
16
}
17
}
18
);
Copied!
1
# Insert here the initialization code as outlined on this page:
2
# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
post_inputs_response = stub.PostInputs(
5
service_pb2.PostInputsRequest(
6
inputs=[
7
resources_pb2.Input(
8
data=resources_pb2.Data(
9
image=resources_pb2.Image(
10
url="https://samples.clarifai.com/metro-north.jpg",
11
allow_duplicate_url=True
12
)
13
)
14
)
15
]
16
),
17
metadata=metadata
18
)
19
20
if post_inputs_response.status.code != status_code_pb2.SUCCESS:
21
print("There was an error with your request!")
22
print("\tCode: {}".format(post_inputs_response.outputs[0].status.code))
23
print("\tDescription: {}".format(post_inputs_response.outputs[0].status.description))
24
print("\tDetails: {}".format(post_inputs_response.outputs[0].status.details))
25
raise Exception("Post inputs failed, status: " + post_inputs_response.status.description)
Copied!
1
var response = client.PostInputs(
2
new PostInputsRequest()
3
{
4
UserAppId = new UserAppIDSet()
5
{
6
UserId = "{YOUR_USER_ID}",
7
AppId = "{YOUR_APP_ID}"
8
},
9
Inputs =
10
{
11
new List<Input>()
12
{
13
new Input()
14
{
15
Data = new Data()
16
{
17
Image = new Image()
18
{
19
Url = "https://samples.clarifai.com/metro-north.jpg",
20
AllowDuplicateUrl = true // optional
21
}
22
}
23
}
24
}
25
}
26
},
27
metadata
28
);
29
30
if (response.Status.Code != StatusCode.Success)
31
throw new Exception("Request failed, response: " + response);
Copied!
1
curl -X POST \
2
-H "Authorization: Key YOUR_API_KEY" \
3
-H "Content-Type: application/json" \
4
-d '
5
{
6
"inputs": [
7
{
8
"data": {
9
"image": {
10
"url": "https://samples.clarifai.com/metro-north.jpg",
11
"allow_duplicate_url": true
12
}
13
}
14
}
15
]
16
}'\
17
https://api.clarifai.com/v2/inputs
Copied!
1
const raw = JSON.stringify({
2
"user_app_id": {
3
"user_id": "{YOUR_USER_ID}",
4
"app_id": "{YOUR_APP_ID}"
5
},
6
"inputs": [
7
{
8
"data": {
9
"image": {
10
"url": "https://samples.clarifai.com/metro-north.jpg",
11
"allow_duplicate_url": true
12
}
13
}
14
}
15
]
16
});
17
18
const requestOptions = {
19
method: 'POST',
20
headers: {
21
'Accept': 'application/json',
22
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
23
},
24
body: raw
25
};
26
27
fetch("https://api.clarifai.com/v2/inputs", requestOptions)
28
.then(response => response.text())
29
.then(result => console.log(result))
30
.catch(error => console.log('error', error));
Copied!

Add an input using bytes

The data must be base64 encoded. When you add a base64 image to our servers, a copy will be stored and hosted on our servers. If you already have an image hosting service we recommend using it and adding images via the url parameter.
Java
NodeJS
Python
C#
cURL
Javascript (REST)
1
import com.clarifai.grpc.api.*;
2
import com.clarifai.grpc.api.status.*;
3
import com.google.protobuf.ByteString;
4
import java.io.File;
5
import java.nio.file.Files;
6
7
// Insert here the initialization code as outlined on this page:
8
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
9
10
MultiInputResponse postInputsResponse = stub.postInputs(
11
PostInputsRequest.newBuilder().addInputs(
12
Input.newBuilder().setData(
13
Data.newBuilder().setImage(
14
Image.newBuilder()
15
.setBase64(ByteString.copyFrom(Files.readAllBytes(
16
new File("{YOUR_IMAGE_LOCATION}").toPath()
17
)))
18
)
19
)
20
).build()
21
);
22
23
if (postInputsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
24
throw new RuntimeException("Post inputs failed, status: " + postInputsResponse.getStatus());
25
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
const fs = require("fs");
5
const imageBytes = fs.readFileSync("{YOUR_IMAGE_LOCATION}");
6
7
stub.PostInputs(
8
{
9
inputs: [{data: {image: {base64: imageBytes}}}]
10
},
11
metadata,
12
(err, response) => {
13
if (err) {
14
throw new Error(err);
15
}
16
17
if (response.status.code !== 10000) {
18
throw new Error("Post inputs failed, status: " + response.status.description);
19
}
20
}
21
);
Copied!
1
# Insert here the initialization code as outlined on this page:
2
# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
with open("{YOUR_IMAGE_LOCATION}", "rb") as f:
5
file_bytes = f.read()
6
7
post_inputs_response = stub.PostInputs(
8
service_pb2.PostInputsRequest(
9
inputs=[
10
resources_pb2.Input(
11
data=resources_pb2.Data(
12
image=resources_pb2.Image(
13
base64=file_bytes
14
)
15
)
16
)
17
]
18
),
19
metadata=metadata
20
)
21
22
if post_inputs_response.status.code != status_code_pb2.SUCCESS:
23
print("There was an error with your request!")
24
print("\tCode: {}".format(post_inputs_response.outputs[0].status.code))
25
print("\tDescription: {}".format(post_inputs_response.outputs[0].status.description))
26
print("\tDetails: {}".format(post_inputs_response.outputs[0].status.details))
27
raise Exception("Post inputs failed, status: " + post_inputs_response.status.description)
Copied!
1
var response = client.PostInputs(
2
new PostInputsRequest()
3
{
4
UserAppId = new UserAppIDSet()
5
{
6
UserId = "{YOUR_USER_ID}",
7
AppId = "{YOUR_APP_ID}"
8
},
9
Inputs =
10
{
11
new List<Input>()
12
{
13
new Input()
14
{
15
Data = new Data()
16
{
17
Image = new Image()
18
{
19
Base64 = "{YOUR_IMAGE_BYTES_STRING}",
20
AllowDuplicateUrl = true // optional
21
}
22
}
23
}
24
}
25
}
26
},
27
metadata
28
);
29
30
if (response.Status.Code != StatusCode.Success)
31
throw new Exception("Request failed, response: " + response);
Copied!
1
curl -X POST \
2
-H "Authorization: Key YOUR_API_KEY" \
3
-H "Content-Type: application/json" \
4
-d '
5
{
6
"inputs": [
7
{
8
"data": {
9
"image": {
10
"base64": '"`base64 /home/user/image.jpeg`"'"
11
}
12
}
13
}
14
]
15
}'\
16
https://api.clarifai.com/v2/inputs
Copied!
1
const raw = JSON.stringify({
2
"user_app_id": {
3
"user_id": "{YOUR_USER_ID}",
4
"app_id": "{YOUR_APP_ID}"
5
},
6
"inputs": [
7
{
8
"data": {
9
"image": {
10
"base64": "{YOUR_BYTES_STRING}"
11
},
12
}
13
}
14
]
15
});
16
17
const requestOptions = {
18
method: 'POST',
19
headers: {
20
'Accept': 'application/json',
21
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
22
},
23
body: raw
24
};
25
26
fetch("https://api.clarifai.com/v2/inputs", requestOptions)
27
.then(response => response.text())
28
.then(result => console.log(result))
29
.catch(error => console.log('error', error));
Copied!

Add multiple inputs with ids

In cases where you have your own id and you only have one item per image, you are encouraged to send inputs with your own id. This will help you later match the input to your own database. If you do not send an id, one will be created for you. If you have more than one item per image, it is recommended that you put the product id in metadata.
Java
NodeJS
Python
C#
cURL
Javascript (REST)
1
import com.clarifai.grpc.api.*;
2
import com.clarifai.grpc.api.status.*;
3
4
// Insert here the initialization code as outlined on this page:
5
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
6
7
MultiInputResponse postInputsResponse = stub.postInputs(
8
PostInputsRequest.newBuilder()
9
.addInputs(
10
Input.newBuilder()
11
.setId("train1")
12
.setData(
13
Data.newBuilder().setImage(
14
Image.newBuilder()
15
.setUrl("https://samples.clarifai.com/metro-north.jpg")
16
.setAllowDuplicateUrl(true)
17
)
18
)
19
)
20
.addInputs(
21
Input.newBuilder()
22
.setId("puppy1")
23
.setData(
24
Data.newBuilder().setImage(
25
Image.newBuilder()
26
.setUrl("https://samples.clarifai.com/puppy.jpeg")
27
.setAllowDuplicateUrl(true)
28
)
29
)
30
)
31
.build()
32
);
33
34
if (postInputsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
35
for (Input input : postInputsResponse.getInputsList()) {
36
System.out.println("Input " + input.getId() + " status: ");
37
System.out.println(input.getStatus() + "\n");
38
}
39
40
throw new RuntimeException("Post inputs failed, status: " + postInputsResponse.getStatus());
41
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
stub.PostInputs(
5
{
6
inputs: [
7
{
8
id: "train1",
9
data: {image: {url: "https://samples.clarifai.com/metro-north.jpg", allow_duplicate_url: true}}
10
},
11
{
12
id: "puppy1",
13
data: {image: {url: "https://samples.clarifai.com/puppy.jpeg", allow_duplicate_url: true}}
14
},
15
]
16
},
17
metadata,
18
(err, response) => {
19
if (err) {
20
throw new Error(err);
21
}
22
23
if (response.status.code !== 10000) {
24
for (const input of response.inputs) {
25
console.log("Input " + input.id + " status: ");
26
console.log(JSON.stringify(input.status, null, 2) + "\n");
27
}
28
29
throw new Error("Post inputs failed, status: " + response.status.description);
30
}
31
}
32
);
Copied!
1
# Insert here the initialization code as outlined on this page:
2
# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
post_inputs_response = stub.PostInputs(
5
service_pb2.PostInputsRequest(
6
inputs=[
7
resources_pb2.Input(
8
id="train1",
9
data=resources_pb2.Data(
10
image=resources_pb2.Image(
11
url="https://samples.clarifai.com/metro-north.jpg",
12
allow_duplicate_url=True
13
)
14
)
15
),
16
resources_pb2.Input(
17
id="puppy1",
18
data=resources_pb2.Data(
19
image=resources_pb2.Image(
20
url="https://samples.clarifai.com/puppy.jpeg",
21
allow_duplicate_url=True
22
)
23
)
24
),
25
]
26
),
27
metadata=metadata
28
)
29
30
if post_inputs_response.status.code != status_code_pb2.SUCCESS:
31
print("There was an error with your request!")
32
for input_object in post_inputs_response.inputs:
33
print("Input " + input_object.id + " status:")
34
print(input_object.status)
35
print("\tCode: {}".format(post_inputs_response.outputs[0].status.code))
36
print("\tDescription: {}".format(post_inputs_response.outputs[0].status.description))
37
print("\tDetails: {}".format(post_inputs_response.outputs[0].status.details))
38
raise Exception("Post inputs failed, status: " + post_inputs_response.status.description)
Copied!
1
var response = client.PostInputs(
2
new PostInputsRequest()
3
{
4
UserAppId = new UserAppIDSet()
5
{
6
UserId = "{YOUR_USER_ID}",
7
AppId = "{YOUR_APP_ID}"
8
},
9
Inputs =
10
{
11
new List<Input>()
12
{
13
new Input()
14
{
15
Id = "train1"
16
Data = new Data()
17
{
18
Image = new Image()
19
{
20
Url = "https://samples.clarifai.com/metro-north.jpg",
21
AllowDuplicateUrl = true // optional
22
}
23
}
24
}
25
},
26
{
27
new Input()
28
{
29
Id = "puppy1"
30
Data = new Data()
31
{
32
Image = new Image()
33
{
34
Url = "https://samples.clarifai.com/puppy.jpeg",
35
AllowDuplicateUrl = true // optional
36
}
37
}
38
}
39
}
40
}
41
},
42
metadata
43
);
44
45
if (response.Status.Code != StatusCode.Success)
46
throw new Exception("Request failed, response: " + response);
Copied!
1
curl -X POST \
2
-H "Authorization: Key YOUR_API_KEY" \
3
-H "Content-Type: application/json" \
4
-d '
5
{
6
"inputs": [
7
{
8
"data": {
9
"image": {
10
"url": "https://samples.clarifai.com/metro-north.jpg",
11
"allow_duplicate_url": true
12
}
13
},
14
"id": "train1"
15
},
16
{
17
"data": {
18
"image": {
19
"url": "https://samples.clarifai.com/puppy.jpeg",
20
"allow_duplicate_url": true
21
}
22
},
23
"id": "puppy1"
24
}
25
]
26
}'\
27
https://api.clarifai.com/v2/inputs
Copied!
1
const raw = JSON.stringify({
2
"user_app_id": {
3
"user_id": "{YOUR_USER_ID}",
4
"app_id": "{YOUR_APP_ID}"
5
},
6
"inputs": [
7
{
8
"data": {
9
"image": {
10
"url": "https://samples.clarifai.com/metro-north.jpg",
11
"allow_duplicate_url": true
12
}
13
},
14
"id": "input1"
15
},
16
{
17
"data": {
18
"image": {
19
"url": "https://samples.clarifai.com/puppy.jpeg",
20
"allow_duplicate_url": true
21
}
22
},
23
"id": "puppy1"
24
}
25
]
26
});
27
28
const requestOptions = {
29
method: 'POST',
30
headers: {
31
'Accept': 'application/json',
32
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
33
},
34
body: raw
35
};
36
37
fetch("https://api.clarifai.com/v2/inputs", requestOptions)
38
.then(response => response.text())
39
.then(result => console.log(result))
40
.catch(error => console.log('error', error));
Copied!

Add inputs with concepts

If you would like to add an input with concepts, you can do so like this. Concepts play an important role in creating your own models using your own concepts. You can learn more about creating your own models above. Concepts also help you search for inputs. You can learn more about search here.
When you add a concept to an input, you need to indicate whether the concept is present in the image or if it is not present.
You can add inputs with concepts as either a URL or bytes.
Java
NodeJS
Python
C#
cURL
Javascript (REST)
1
import com.clarifai.grpc.api.*;
2
import com.clarifai.grpc.api.status.*;
3
4
// Insert here the initialization code as outlined on this page:
5
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
6
7
MultiInputResponse postInputsResponse = stub.postInputs(
8
PostInputsRequest.newBuilder().addInputs(
9
Input.newBuilder().setData(
10
Data.newBuilder()
11
.setImage(
12
Image.newBuilder()
13
.setUrl("https://samples.clarifai.com/puppy.jpeg")
14
.setAllowDuplicateUrl(true)
15
)
16
.addConcepts(
17
Concept.newBuilder()
18
.setId("charlie")
19
.setValue(1f)
20
)
21
)
22
).build()
23
);
24
25
if (postInputsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
26
throw new RuntimeException("Post inputs failed, status: " + postInputsResponse.getStatus());
27
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
stub.PostInputs(
5
{
6
inputs: [{data: {
7
image: {url: "https://samples.clarifai.com/puppy.jpeg", allow_duplicate_url: true},
8
concepts: [{id: "charlie", value: 1.}]
9
}}]
10
},
11
metadata,
12
(err, response) => {
13
if (err) {
14
throw new Error(err);
15
}
16
17
if (response.status.code !== 10000) {
18
throw new Error("Post inputs failed, status: " + response.status.description);
19
}
20
}
21
);
Copied!
1
# Insert here the initialization code as outlined on this page:
2
# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
post_inputs_response = stub.PostInputs(
5
service_pb2.PostInputsRequest(
6
inputs=[
7
resources_pb2.Input(
8
data=resources_pb2.Data(
9
image=resources_pb2.Image(
10
url="https://samples.clarifai.com/puppy.jpeg",
11
allow_duplicate_url=True
12
),
13
concepts=[resources_pb2.Concept(id="charlie", value=1.)]
14
)
15
)
16
]
17
),
18
metadata=metadata
19
)
20
21
if post_inputs_response.status.code != status_code_pb2.SUCCESS:
22
print("There was an error with your request!")
23
print("\tCode: {}".format(post_inputs_response.outputs[0].status.code))
24
print("\tDescription: {}".format(post_inputs_response.outputs[0].status.description))
25
print("\tDetails: {}".format(post_inputs_response.outputs[0].status.details))
26
raise Exception("Post inputs failed, status: " + post_inputs_response.status.description)
Copied!
1
var response = client.PostInputs(
2
new PostInputsRequest()
3
{
4
UserAppId = new UserAppIDSet()
5
{
6
UserId = "{YOUR_USER_ID}",
7
AppId = "{YOUR_APP_ID}"
8
},
9
Inputs =
10
{
11
new List<Input>()
12
{
13
new Input()
14
{
15
Data = new Data()
16
{
17
Image = new Image()
18
{
19
Url = "https://samples.clarifai.com/puppy.jpeg",
20
AllowDuplicateUrl = true // optional
21
},
22
Concepts =
23
{
24
new List<Concept>
25
{
26
new Concept
27
{
28
Id = "charlie",
29
Value = 1
30
}
31
}
32
}
33
}
34
}
35
}
36
}
37
},
38
metadata
39
);
40
41
if (response.Status.Code != StatusCode.Success)
42
throw new Exception("Request failed, response: " + response);
Copied!
1
curl -X POST \
2
-H "Authorization: Key YOUR_API_KEY" \
3
-H "Content-Type: application/json" \
4
-d '
5
{
6
"inputs": [
7
{
8
"data": {
9
"image": {
10
"url": "https://samples.clarifai.com/puppy.jpeg",
11
"allow_duplicate_url": true
12
},
13
"concepts":[
14
{
15
"id": "charlie",
16
"value": 1
17
}
18
]
19
}
20
}
21
]
22
}'\
23
https://api.clarifai.com/v2/inputs
Copied!
1
const raw = JSON.stringify({
2
"user_app_id": {
3
"user_id": "{YOUR_USER_ID}",
4
"app_id": "{YOUR_APP_ID}"
5
},
6
"inputs": [
7
{
8
"data": {
9
"image": {
10
"url": "https://samples.clarifai.com/puppy.jpeg",
11
"allow_duplicate_url": true
12
},
13
// Optionally add a concept with your input
14
"concepts": [
15
{
16
"id": "charlie",
17
"value": 1
18
}
19
]
20
}
21
}
22
]
23
});
24
25
const requestOptions = {
26
method: 'POST',
27
headers: {
28
'Accept': 'application/json',
29
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
30
},
31
body: raw
32
};
33
34
fetch("https://api.clarifai.com/v2/inputs", requestOptions)
35
.then(response => response.text())
36
.then(result => console.log(result))
37
.catch(error => console.log('error', error));
Copied!

Add inputs with custom metadata

In addition to adding an input with concepts, you can also add an input with custom metadata. This metadata will then be searchable. Metadata can be any arbitrary JSON.
If you have more than one item per image it is recommended to put the id in metadata like:
1
{
2
"product_id": "xyz"
3
}
Copied!
Java
NodeJS
Python
cURL
Javascript (REST)
1
import com.clarifai.grpc.api.*;
2
import com.clarifai.grpc.api.status.*;
3
import com.google.protobuf.Struct;
4
import com.google.protobuf.Value;
5
6
// Insert here the initialization code as outlined on this page:
7
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
8
9
MultiInputResponse postInputsResponse = stub.postInputs(
10
PostInputsRequest.newBuilder().addInputs(
11
Input.newBuilder().setData(
12
Data.newBuilder()
13
.setImage(
14
Image.newBuilder()
15
.setUrl("https://samples.clarifai.com/puppy.jpeg")
16
.setAllowDuplicateUrl(true)
17
)
18
.setMetadata(
19
Struct.newBuilder()
20
.putFields("id", Value.newBuilder().setStringValue("id001").build())
21
.putFields("type", Value.newBuilder().setStringValue("animal").build())
22
.putFields("size", Value.newBuilder().setNumberValue(100).build())
23
)
24
)
25
).build()
26
);
27
28
if (postInputsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
29
throw new RuntimeException("Post inputs failed, status: " + postInputsResponse.getStatus());
30
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
stub.PostInputs(
5
{
6
inputs: [{data: {
7
image: {url: "https://samples.clarifai.com/puppy.jpeg", allow_duplicate_url: true},
8
metadata: {id: "id001", type: "animal", size: 100}
9
}}]
10
},
11
metadata,
12
(err, response) => {
13
if (err) {
14
throw new Error(err);
15
}
16
17
if (response.status.code !== 10000) {
18
throw new Error("Post inputs failed, status: " + response.status.description);
19
}
20
}
21
);
Copied!
1
from google.protobuf.struct_pb2 import Struct
2
3
# Insert here the initialization code as outlined on this page:
4
# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
5
6
input_metadata = Struct()
7
input_metadata.update({"id": "id001", "type": "animal", "size": 100})
8
9
post_inputs_response = stub.PostInputs(
10
service_pb2.PostInputsRequest(
11
inputs=[
12
resources_pb2.Input(
13
data=resources_pb2.Data(
14
image=resources_pb2.Image(
15
url="https://samples.clarifai.com/puppy.jpeg",
16
allow_duplicate_url=True
17
),
18
metadata=input_metadata
19
)
20
)
21
]
22
),
23
metadata=metadata
24
)
25
26
if post_inputs_response.status.code != status_code_pb2.SUCCESS:
27
print("There was an error with your request!")
28
print("\tCode: {}".format(post_inputs_response.outputs[0].status.code))
29
print("\tDescription: {}".format(post_inputs_response.outputs[0].status.description))
30
print("\tDetails: {}".format(post_inputs_response.outputs[0].status.details))
31
raise Exception("Post inputs failed, status: " + post_inputs_response.status.description)
Copied!
1
curl -X POST \
2
-H "Authorization: Key YOUR_API_KEY" \
3
-H "Content-Type: application/json" \
4
-d '
5
{
6
"inputs": [
7
{
8
"data": {
9
"image": {
10
"url": "https://samples.clarifai.com/puppy.jpeg",
11
"allow_duplicate_url": true
12
},
13
"metadata": {"id": "id001", "type": "animal", "size": 100}
14
}
15
}
16
]
17
}'\
18
https://api.clarifai.com/v2/inputs
Copied!
1
const raw = JSON.stringify({
2
"user_app_id": {
3
"user_id": "{YOUR_USER_ID}",
4
"app_id": "{YOUR_APP_ID}"
5
},
6
"inputs": [
7
{
8
"data": {
9
"image": {
10
"url": "https://samples.clarifai.com/puppy.jpeg",
11
"allow_duplicate_url": true
12
},
13
"metadata": {"id": "id001", "type": "animal", "size": 100}
14
}
15
}
16
]
17
});
18
19
const requestOptions = {
20
method: 'POST',
21
headers: {
22
'Accept': 'application/json',
23
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
24
},
25
body: raw
26
};
27
28
fetch("https://api.clarifai.com/v2/inputs", requestOptions)
29
.then(response => response.text())
30
.then(result => console.log(result))
31
.catch(error => console.log('error', error));
Copied!

List inputs

You can list all the inputs (images) you have previously added either for search or train.
If you added inputs with concepts, they will be returned in the response as well.