How Unkey can help accelerate your AI development

Building AI projects and protecting the API can be a daunting task. With Unkey we simplify the experience.

Written by

James Perkins

Published on

Artificial Intelligence (AI) has undeniably transformed the technology landscape in the past few years. From OpenAI to Llama 2, AI has permeated every facet of our lives. Yet, as with any groundbreaking technology, developers face unique challenges when working on AI projects. This is where Unkey comes in. Unkey's API management platform helps developers secure, manage, and scale their APIs.

What is Unkey?

Unkey is an open source API management platform, that provides a low-latency option to create, manage and revoke API Keys for your API. We offer features like:

  • Rate limiting per key
  • Temporary keys
  • Limited use keys

Unkey also offers seamless integration with popular programming languages making it easier for developers to work in an environment they are comfortable with. Whether you are a Typescript, Python, or a Go developer you can use Unkey in minutes.

How Unkey Can Help AI Projects

When it comes to AI project development, Unkey is a game-changer. It aids in streamlining the API development process. With our robust features, Unkey allows developers to focus on the creative aspects of AI development rather than getting bogged down with how to secure their APIs.

For instance, consider developing an application that interacts with OpenAPI, you want users to be able to use your service but you don't want them to be able to abuse it. If you handle this yourself you need to think about:

  1. How do I identify the user
  2. Implement a rate limiting system.
  3. Implement a token system to allow them to use X tokens
  4. Make sure it's fast.

With Unkey you can simplify this by adding in a single API call to create a user's API Key with both a token system and rate limiting built in. Below is an example of a cURL request that creates a key with rate limiting of 10 requests, that refill at a rate of 1 request per second. The key also has 100 total requests allowed before they can no longer access the resource.

 1curl --request POST \
 2  --url https://api.unkey.dev/v1/keys.createKey \
 3  --header 'Authorization: Bearer <UNKEY>' \
 4  --header 'Content-Type: application/json' \
 5  --data '{
 6	"apiId":"<API_ID>",
 7	"ratelimit":{
 8		"type":"fast",
 9		"limit":10,
10		"refillRate": 1,
11		"refillInterval": 1000
12	},
13	"remaining": 100
14}'

The response includes the key itself, which you should pass on to your user and a keyId, which you can use later to update or revoke the key. Don’t worry about storing the keyId, you can always query it later from Unkey when you need it.

 1{
 2  "key": "prefix_5AkwpYpIHntGBpTHLqKg",
 3  "keyId": "key_123"
 4}

So now you have an API key, but how does that help you protect your AI project? Unkey provides a verify endpoint, this endpoint can verify a request in under 40 ms and provide you with the details you need to make a business decision. For example:

 1curl --request POST \
 2  --url https://api.unkey.dev/v1/keys.verifyKey \
 3  --header 'Content-Type: application/json' \
 4  --data '{
 5    "key":"THE_NEW_KEY"
 6  }'

This returns the following in the body:

 1{
 2   "valid":true,
 3   "remaining":99,
 4   "ratelimit":{
 5      "limit":10,
 6      "remaining":9,
 7      "reset":1690065988700
 8   }
 9}

As you see Unkey returns "valid": true which allows you to make an immediate business decision, if it is true let them access the resource, if it is false deny them access. On top of that, we return the total remaining requests, which you could return to your user, and finally their rate limits.

Even though these examples are in cURL we have a typescript SDK and community SDKs in Go, Python, Elixir, and a Nuxt module.

How to Start Using Unkey for Your AI Projects

Starting with Unkey for your AI projects is straightforward. To begin, sign up for your free Unkey account. As soon as you create your account you will be asked to create your workspace. Give it a name, and a slug. The name is shown only to you and not to your users.

Next, you need to create a root API Key, this is a special API Key that allows you full read and write access to all current and future resources. It’s important to keep this API Key safe, as it allows you to create, revoke, validate, and delete API Keys. You can do this by selecting settings and then clicking the “Create New Key” button.

Then you can create your first API which allows you to track usage as well as segment keys, the name you choose is also not visible to users.

You are now ready to integrate Unkey into your code! If you are manually issuing keys you can do that right from our dashboard, otherwise you can start reading our documentation and learn about everything we have to offer.

Protect your API.
Start today.

2500 verifications and 100K successful rate‑limited requests per month. No CC required.