Developer Guide

Making Your First Request

Now that you understand endpoints and authentication, let's make actual API calls. NeevCloud provides ready-to-use examples in three popular languages.

cURL Example

cURL is a command-line tool available on most systems. It's excellent for testing API endpoints quickly.

curl https://inference.ai.neevcloud.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-nc-xxxxx" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      { "role": "system", "content": "You are a helpful assistant." },
      { "role": "user", "content": "Explain inference API design." }
    ],
    "max_tokens": 100,
    "temperature": 0.7
  }'

Breaking Down the Request

  • curl https://inference.ai.neevcloud.com/v1/chat/completions – The HTTP client and endpoint URL

  • -H "Authorization: Bearer $NEEV_API_KEY" – Your authentication. Replace $NEEV_API_KEY with your actual key, or set it as an environment variable

  • -H "Content-Type: application/json" – Tells the server you're sending JSON data

  • -d '{...}' – The request body containing your parameters

Request Parameters

  • messages – The conversation history (system, user, assistant roles)

  • model – The specific model name you're using. Must match exactly the model you selected

  • max_tokens – Maximum number of tokens in the response. Limits the output length and costs

  • temperature – Controls randomness (0 = deterministic, 1 = creative)

Response

You'll receive a JSON response containing:

  • The generated text

  • Token counts (input and output)

  • Processing time

  • Any metadata about the request

Python Example

Python is ideal for integrating AI into web applications, data pipelines, and automation scripts.

How This Works

  • Import OpenAI – The official Python library for OpenAI-compatible APIs

  • Initialize client – Configure the OpenAI client with your API key and NeevCloud base URL

  • Make the requestclient.chat.completions.create() sends the request and returns a structured object

  • Use the data – Access content via response.choices[0].message.content

Error Handling

In production code, add error handling:

JavaScript Example

JavaScript is essential for Node.js backends and browser-based applications (though API keys should never be exposed in browser code—use a backend proxy instead).

Understanding the Code

  • Import OpenAI – The official Node.js library for OpenAI-compatible APIs

  • Initialize client – Configure with API key and base URL

  • Make the request – Call client.chat.completions.create() to send data

  • Access results – Read the generated text from response.choices[0].message.content

Using in Node.js (Raw HTTP)

If you prefer using fetch instead of the SDK:

Testing Your Setup

After running any of these examples:

  • Verify the response – You should receive generated text back

  • Check token counts – The response includes input and output token usage

  • Review timing – Note how long the request took

  • Test error cases – Try an invalid API key to confirm error handling works

Once you've successfully made a request, you're ready to integrate the API into your application.

Last updated