> For the complete documentation index, see [llms.txt](https://docs.jetpero.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.jetpero.com/basics/api-requests-and-responses.md).

# API Requests & Responses

### ✅ Making API Requests

All requests through JetPero follow this pattern:

```bash
 https://api.jetpero.com/proxy/<provider-name>/<endpoint>
```

#### 🧠 Example: OpenAI Chat Completion

```bash
curl https://api.jetpero.com/proxy/openai/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <Your-Project-Token>" \
  -d '{
    "model": "gpt-4",
    "messages": [
      {"role": "user", "content": "Tell me a joke"}
    ]
  }'
```

#### 🎨 Example: OpenAI Image Generation

```bash
curl https://api.jetpero.com/proxy/openai/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <Your-Project-Token>" \
  -d '{
    "prompt": "A cyberpunk city at night",
    "n": 1,
    "size": "1024x1024"
  }'

```

### 📥 How the Response Works

JetPero forwards the response from the original provider **exactly as received**, with **no modification to the structure or data**, so your existing integrations will continue to work as expected.

#### Example Response (Chat Completion)

```json
{
  "id": "chatcmpl-1234567890",
  "object": "chat.completion",
  "created": 1712345678,
  "model": "gpt-4",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Why did the web developer leave the restaurant? Because of the table layout."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 14,
    "total_tokens": 24
  }
}
```

***

### 🚨 Common Error Formats

When something goes wrong, JetPero provides clear and consistent error responses, even if the original provider’s format varies.

#### ❌ JetPero Standard Error Example

```json
{
  "error": {
    "status": 401,
    "message": "Invalid project token or expired authentication."
  }
}
```

#### 🔒 Upstream Provider Error Example (Forwarded)

```json
{
  "error": {
    "message": "You exceeded your current quota, please check your plan and billing details.",
    "type": "insufficient_quota",
    "param": null,
    "code": "quota_exceeded"
  }
}
```

> ✅ Tip: JetPero distinguishes between **JetPero proxy errors** and **upstream provider errors**. You can use the HTTP status codes and `error.type` or `code` fields to handle them in your application logic.

***

### 🧪 Testing Your API Call

To verify that your configuration is correct:

1. Use Postman, curl, or your preferred HTTP client.
2. Add the correct `Authorization` header with your **project-specific token**.
3. Use an endpoint that your provider supports (check their official docs).
4. Review both the request and response for debugging.

***

### 🧩 Best Practices

* Always use your **JetPero project token** in the header:

  ```bash
  Authorization: Bearer <Your-Project-Token>
  ```
* Don’t expose your provider API keys — JetPero handles it behind the scenes.
* Keep provider names consistent and lowercase (e.g., `openai`, `huggingface`, `elevenlabs`)
* Handle 4xx and 5xx errors gracefully based on provider docs.
