Grit API Reference

Grit API reference guide for creating, retrieving, canceling, and listing technical articles using HTTP requests or the official Python SDK.

Introduction

You can interact with the API through HTTP requests from any language, via our official Python SDK.

To install, run the following command:

pip install gritholdings

Note that this SDK is currently in private beta. Please reach out to support@meetgrit.com for more information.

Authentication

Grit uses API keys for authentication. Remember that your API key is a secret! Do not share it with others or expose it in any client-side code (browsers, apps). Production requests must be routed through your own backend server where your API key can be securely loaded from an environment variable or key management service.

All API requests should include your API key in an Authorization HTTP header as follows:

Authorization: Bearer GRIT_API_KEY

Example with gritholdings Python package:

from gritholdings import Grit
client = Grit(
  api_key="my_api_key"
)

Create article

POST https://api.meetgrit.com/v1/articles

Creates a technical article. This runs asynchronously. The time frame within which the article should be processed is 24 hours.

Request body

model string (required)
ID of the model to use. Only grit-1 is currently available.
input_text string (Required)
The ID of an input text that contains requests for the new technical article.

Returns

The created Article object.

Example request curl

curl https://api.meetgrit.com/v1/articles \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GRIT_API_KEY" \
  -d '{
    "model": "grit-1",
    "input_text": "## Heading 2\n\Outline content here"
  }'

Example request python

From gritholdings import Grit
client = Grit()
client.create(
  model="grit-1",
  input_text="## Heading 2\n\Outline content here"
)

Response

{
  "id": "article_abc123",
  "errors": null,
  "status": "in_progress",
  "output_text": null,
  "In_progress_at": null,
  "completed_at": null,
  "failed_at": null
}

Retrieve article

GET https://api.meetgrit.com/v1/articles/{article_id}

Retrieves a technical article.

Example request curl

curl https://api.meetgrit.com/v1/articles/article_abc123 \
  -H "Authorization: Bearer $GRIT_API_KEY" \
  -H "Content-Type: application/json" \

Example request python

from gritholdings import Grit
client = Grit()
client.articles.retrieve("article_abc123")

Response

{
  "id": "article_abc123",
  "errors": null,
  "status": "in_progress",
  "output_text": null,
  "In_progress_at": null,
  "completed_at": null,
  "failed_at": null
}

Cancel article

POST https://api.meetgrit.com/v1/articles/{article_id}/cancel

Cancels an in-progress technical article.

Path parameters

article_id string (Required)
The ID of the article to cancel.

Returns

The Article object matching the specified ID

Example request curl

curl https://api.meetgrit.com/v1/articles/article_abc123/cancel \
  -H "Authorization: Bearer $GRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -X POST

Example request python

from gritholdings import Grit
client = Grit()
client.articles.cancel("article_abc123")

Response

{
  "id": "article_abc123",
  "errors": null,
  "status": "in_progress",
  "output_text": null,
  "In_progress_at": null,
  "completed_at": null,
  "failed_at": null
}

List article

GET https://api.meetgrit.com/v1/articles

Query parameters

limit integer (Optional)
Defaults to 5
A limit on the number of objects to be returned. Limit can range between 1 and 25, and the default is 5.

Returns

A list of paginated Article objects.

Example request curl

curl https://api.meetgrit.com/v1/articles?limit=2 \
  -H "Authorization: Bearer $GRIT_API_KEY" \
  -H "Content-Type: application/json"

Example request python

from gritholdings import Grit
client = Grit()
client.articles.list()

Response

{
  "object": "list",
  "data": [
    {
      "id": "article_abc123",
      "errors": null,
      "status": "in_progress",
      "output_text": null,
      "In_progress_at": null,
      "completed_at": null,
      "failed_at": null
    },
    { . . . },
  ],
  "has_more": true
}

The article object

id string

errors array

|> code string
An error code identifying the error type.

|> message string
A human-readable message providing more details about the error.

status string
The current status of the batch.

output_file_id string
The text of the outputs of successfully executed requests.

in_progress_at string
The Unix timestamp (in seconds) for when the batch started processing.

completed_at string
The Unix timestamp (in seconds) for when the batch was completed.

failed_at string
The Unix timestamp (in seconds) for when the batch failed.

The article object

{
  "id": "article_abc123",
  "errors": null,
  "status": "in_progress",
  "output_text": null,
  "In_progress_at": null,
  "completed_at": null,
  "failed_at": null
}

Author

Edward Wong

Last updated