Create, Get, Update, Delete
Manage your concepts.
Within your app you can create concepts, modify them after creation an get them from your app. We currently do not support deleting concepts since they are such an integral tie across almost all other data structures in the platform like inputs, models, searches, etc.
You will find that some of our endpoints have additional information returned from the clarifai/main app which contains our pre-trained models but also a large knowledge graph we've assembled over the years.

Create

Add Concepts

To create a new concept in you app you POST the concept with an id and name. You can also post more than one concept in the same API by sending a list of concepts.
gRPC Java
gRPC NodeJS
gRPC Python
cURL
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
MultiConceptResponse postConceptsResponse = stub.postConcepts(
8
PostConceptsRequest.newBuilder()
9
.addConcepts(Concept.newBuilder().setId("charlie").setName("Charlie Name"))
10
.build()
11
);
12
13
if (postConceptsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
14
throw new RuntimeException("Post concepts failed, status: " + postConceptsResponse.getStatus());
15
}
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.PostConcepts(
5
{
6
concepts: [{id: "charlie", name: "Charlie Name"}]
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 concepts 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_concepts_response = stub.PostConcepts(
5
service_pb2.PostConceptsRequest(
6
concepts=[resources_pb2.Concept(id="charlie", name="Charlie Name")]
7
),
8
metadata=metadata
9
)
10
11
if post_concepts_response.status.code != status_code_pb2.SUCCESS:
12
raise Exception("Post concept failed, status: " + post_concepts_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
"concepts": [
7
{
8
"id": "{concept_id}",
9
"name": "{new_concept_name}"
10
}
11
]
12
}'\
13
https://api.clarifai.com/v2/concepts
Copied!

Get

Get Concept by ID

You can get a singular concept by its ID.
gRPC Java
gRPC NodeJS
gRPC Python
cURL
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
SingleConceptResponse getConceptResponse = stub.getConcept(
8
GetConceptRequest.newBuilder()
9
.setConceptId("charlie")
10
.build()
11
);
12
13
if (getConceptsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
14
throw new RuntimeException("Get concepts failed, status: " + getConceptsResponse.getStatus());
15
}
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.GetConcept(
5
{
6
concept_id: "bosco"
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("Get concepts 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
get_concepts_response = stub.GetConcept(
5
service_pb2.GetConceptRequest(
6
concept_id="charlie"
7
),
8
metadata=metadata
9
)
10
11
if get_concepts_response.status.code != status_code_pb2.SUCCESS:
12
raise Exception("Get concept failed, status: " + get_concepts_response.status.description)
Copied!
1
curl -X GET \
2
-H "Authorization: Key YOUR_API_KEY" \
3
-H "Content-Type: application/json" \
4
https://api.clarifai.com/v2/concepts/{concept_id}
Copied!

List concepts

You can get a list of concepts within your app with a GET call. This call supports pagination.
gRPC Java
gRPC NodeJS
gRPC Python
cURL
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
MultiConceptResponse listConceptsResponse = stub.listConcepts(
8
ListConceptsRequest.newBuilder()
9
.build()
10
);
11
12
if (listConceptsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
13
throw new RuntimeException("List concepts failed, status: " + listConceptsResponse.getStatus());
14
}
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.ListConcepts(
5
{},
6
metadata,
7
(err, response) => {
8
if (err) {
9
throw new Error(err);
10
}
11
12
if (response.status.code !== 10000) {
13
throw new Error("List concepts failed, status: " + response.status.description);
14
}
15
}
16
);
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
list_concepts_response = stub.ListConcepts(
5
service_pb2.ListConceptsRequest(),
6
metadata=metadata
7
)
8
9
if list_concepts_response.status.code != status_code_pb2.SUCCESS:
10
raise Exception("List concept failed, status: " + list_concepts_response.status.description)
Copied!
1
curl -X GET \
2
-H "Authorization: Key YOUR_API_KEY" \
3
-H "Content-Type: application/json" \
4
https://api.clarifai.com/v2/concepts
Copied!

Update

Update Concept Name

The code below showcases how to update a concept's name given its id by using the "overwrite" action. You can also patch multiple concepts by sending a list of concepts.
gRPC Java
gRPC NodeJS
gRPC Python
js
python
java
csharp
objective-c
php
cURL
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
MultiConceptResponse patchConceptsResponse = stub.patchConcepts(
8
PatchConceptsRequest.newBuilder()
9
.setAction("overwrite") // The only supported action right now is overwrite.
10
.addConcepts(Concept.newBuilder().setId("charlie").setName("Charlie Name"))
11
.build()
12
);
13
14
if (patchConceptsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
15
throw new RuntimeException("Patch concepts failed, status: " + patchConceptsResponse.getStatus());
16
}
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.PatchConcepts(
5
{
6
action: "overwrite", // The only supported action right now is overwrite
7
concepts: [{id: "charlie", name: "Charlie Name"}]
8
},
9
metadata,
10
(err, response) => {
11
if (err) {
12
throw new Error(err);
13
}
14
15
if (response.status.code !== 10000) {
16
throw new Error("Patch concepts failed, status: " + response.status.description);
17
}
18
}
19
);
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
patch_concepts_response = stub.PatchConcepts(
5
service_pb2.PatchConceptsRequest(
6
action="overwrite", # The only supported action right now is overwrite.
7
concepts=[resources_pb2.Concept(id="charlie", name="Charlie Name")]
8
),
9
metadata=metadata
10
)
11
12
if patch_concepts_response.status.code != status_code_pb2.SUCCESS:
13
raise Exception("Patch concept failed, status: " + patch_concepts_response.status.description)
Copied!
1
** Coming Soon
Copied!
1
from clarifai.rest import ClarifaiApp
2
app = ClarifaiApp(api_key='YOUR_API_KEY')
3
4
app.concepts.update(concept_id='concept_id', concept_name='new_concept_name')
Copied!
1
** Coming Soon
Copied!
1
using System.Threading.Tasks;
2
using Clarifai.API;
3
using Clarifai.DTOs.Predictions;
4
5
namespace YourNamespace
6
{
7
public class YourClassName
8
{
9
public static async Task Main()
10
{
11
var client = new ClarifaiClient("YOUR_API_KEY");
12
13
await client.ModifyConcepts(
14
new Concept("{concept-id}", name: "{new-concept-name}"))
15
.ExecuteAsync();
16
}
17
}
18
}
Copied!
1
** Coming Soon
Copied!
1
use Clarifai\API\ClarifaiClient;
2
use Clarifai\DTOs\Predictions\Concept;
3
4
$client = new ClarifaiClient('YOUR_API_KEY');
5
6
$response = $client->modifyConcepts((new Concept('CONCEPT'))->withName('UPDATED_CONCEPT_NAME'))
7
->executeSync();
8
9
if ($response->isSuccessful()) {
10
echo "Response is successful.\n";
11
} else {
12
echo "Response is not successful. Reason: \n";
13
echo $response->status()->description() . "\n";
14
echo $response->status()->errorDetails() . "\n";
15
echo "Status code: " . $response->status()->statusCode();
16
}
Copied!
1
curl -X PATCH \
2
-H "Authorization: Key YOUR_API_KEY" \
3
-H "Content-Type: application/json" \
4
-d '
5
{
6
"concepts": [
7
{
8
"id": "charlie",
9
"name": "Charlie Name"
10
}
11
],
12
"action": "overwrite"
13
}'\
14
https://api.clarifai.com/v2/concepts
Copied!
Last modified 1d ago