Quickstart
We show these steps using the curl command to make the JSON output clear and straightforward. You can also perform all these actions through our easy-to-use website, so you can choose what works best for you.
Make Your First Call
Before making Inference API requests, you must grab your API key from your settings.
After you have your API key, you can make your first call to an Inference API. Below, you can see how to send a POST request to the OpenAI chat completions API available in Xinfer.AI.
XINFERAI_KEY=...
curl -X POST \
"https://api.xinfer.ai/api/8wb282el2/completions/v1" \
-H "accept: application/json" \
-H "Authorization: Bearer $XINFERAI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "Explain Open API in one sentence."
}
]
}'
Please be aware that the call will consume your Inference API credits. If your credit runs out, XInfer.AI will charge you.
Try our API Playground. The interactive OpenAPI client uses your login credentials and allows you to set inputs and make API calls in real time, providing a hands-on way to explore and understand the API's capabilities.
Publish Your First API
Once you have your API key, you can submit your first Inference API. Below, we use a simple demo API to simulate the Inference API you want to submit. We set it to charge $2 per million requests.
To submit an API, your key needs to have scopes include one of the owner, admin, and developer; otherwise, you will get the error - Insufficient scope.
Following the tabs: Test -> Submit -> Response -> Verify.
# the api key for demo api is demo-key
curl -X POST https://api.xinfer.ai/demos/a-plus-b \
-H "Accept: application/json" \
-H "Authorization: Bearer demo-key" \
-H "Content-Type: application/json" \
-d '{ "a": 1, "b": 2}'
{"result":3}
Since the new API is in preview mode, the verify call URL has the query string preview=true. Once you are satisfied with the result and ready to accept traffic, you can publish it:
Please be aware that once your API is published to the public, you are only allowed to change a few advanced settings.
XINFERAI_KEY=...
id=1234
# use the id from previous response
curl -X PUT "https://api.xinfer.ai/utils/inferences/v1/$id?publish=true" \
-H "Accept: application/json" \
-H "Authorization: Bearer $XINFERAI_KEY" \
-H "Content-Type: application/json" \
-d "{}"
{"data":{"id":1234}}
Then wait for approval and feedback from Xinfer.AI team.
The review process may take a few hours to a few days, our review team may communicate back with questions to better understand your work.
Try the API Configure Editor
. You can create, modify, submit, publish, and delete your inference APIs through this editor. Additionally, it provides explanations to help you understand each configuration option. You can access it through the list view of your APIs, or the API submit link to create a new API.
What's next?
Now, we have a good idea of how to make AI Inference API calls and publish an AI Inference solution via API. But we still need to answer two critical questions:
- How do the users know to use my inference API?
- How do the users find my solution?
Open API Specification (OAS) is the answer. Let's see how OAS helps solve these issues.