# Look up a past request

Source: https://router.africa/docs/api-reference/get-generation

`GET https://api.router.africa/v1/generation`

The metadata of one past request, by its request id (the `x-request-id`
header of that response). Metadata only: prompts and responses are never
returned, and there is no endpoint that returns them.

Only requests from the calling key's workspace can be read. Any other id,
and an unknown id, return the same `404`.

The record is written after the response is sent, so a lookup straight
after a request can return `404` for a short while. Retry.

Amounts are credits.

## Authentication

Send your key as `Authorization: Bearer YOUR_KEY`. Never put a key in the URL or the body: the request is refused with `key_not_in_header`.

## Parameters

- `Authorization` (header, string, required): Bearer YOUR_KEY.
- `id` (query, string, required): The request id to look up.

## Example request

**curl**

```bash
curl "https://api.router.africa/v1/generation?id=0192f0e0-7a1c-7d3e-9f10-2b6c8a4d5e11" \
  -H "Authorization: Bearer $ROUTER_AFRICA_API_KEY"
```

**Python**

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.router.africa/v1",
    api_key=os.environ["ROUTER_AFRICA_API_KEY"],
)

print(client.get("/generation", options={"params": {"id": "0192f0e0-7a1c-7d3e-9f10-2b6c8a4d5e11"}}, cast_to=object))
```

**TypeScript**

```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.router.africa/v1",
  apiKey: process.env.ROUTER_AFRICA_API_KEY,
});

console.log(await client.get("/generation", { query: { id: "0192f0e0-7a1c-7d3e-9f10-2b6c8a4d5e11" } }));
```

## Response

The request's metadata.

- `data` (object, required)
  - `id` (string, required): The request id.
  - `created_at` (string, required): Format: date-time
  - `endpoint` (string, required): The path that was called, for example `/v1/chat/completions`.
  - `model` (string, required)
  - `status_code` (integer, required): The HTTP status the request returned.
  - `error_code` (string | null, required): The error `reason`, or null when the request succeeded.
  - `latency_ms` (integer, required)
  - `streamed` (boolean, required)
  - `input_tokens` (integer, required)
  - `output_tokens` (integer, required)
  - `cost` (string, required): The charge, in credits. Pattern: `^[0-9]+\.[0-9]{8}$`

```json
{
  "data": {
    "id": "0192f0e0-7a1c-7d3e-9f10-2b6c8a4d5e11",
    "created_at": "2026-11-07T09:30:00Z",
    "endpoint": "/v1/chat/completions",
    "model": "openai/gpt-4.1-mini",
    "status_code": 200,
    "error_code": null,
    "latency_ms": 840,
    "streamed": false,
    "input_tokens": 12,
    "output_tokens": 3,
    "cost": "0.00000240"
  }
}
```

## Errors

### 400

The request is malformed or fails validation.

400 invalid_body

```json
{
  "error": {
    "code": 400,
    "message": "Request body is invalid: `messages` is required.",
    "metadata": {
      "error_type": "invalid_request",
      "reason": "invalid_body"
    }
  }
}
```

400 key_not_in_header

```json
{
  "error": {
    "code": 400,
    "message": "Send your API key in the Authorization header, not the URL or body.",
    "metadata": {
      "error_type": "invalid_request",
      "reason": "key_not_in_header"
    }
  }
}
```

400 context_length_exceeded

```json
{
  "error": {
    "code": 400,
    "message": "The request is too long for `openai/gpt-4.1-mini`'s context window. Shorten the input and retry.",
    "metadata": {
      "error_type": "context_length_exceeded",
      "reason": "context_length_exceeded"
    }
  }
}
```

### 401

The API key is missing or not valid. One answer for unknown, malformed, revoked, expired and pending keys.

401 missing_api_key

```json
{
  "error": {
    "code": 401,
    "message": "You didn't provide an API key. Send it as `Authorization: Bearer YOUR_KEY`.",
    "metadata": {
      "error_type": "authentication",
      "reason": "missing_api_key"
    }
  }
}
```

401 invalid_api_key

```json
{
  "error": {
    "code": 401,
    "message": "Incorrect API key provided: sk-ra-…abcd. Check your keys at https://app.router.africa.",
    "metadata": {
      "error_type": "authentication",
      "reason": "invalid_api_key"
    }
  }
}
```

### 403

The account is suspended, or the provider refused the content.

403 account_suspended

```json
{
  "error": {
    "code": 403,
    "message": "This account is suspended. Contact support.",
    "metadata": {
      "error_type": "permission_denied",
      "reason": "account_suspended"
    }
  }
}
```

403 content_policy_violation

```json
{
  "error": {
    "code": 403,
    "message": "The request was blocked by the model provider's content policy.",
    "metadata": {
      "error_type": "content_policy_violation",
      "reason": "content_policy_violation"
    }
  }
}
```

### 404

The model is unknown, off or not allowed for this key (one answer for all three), or the path does not exist.

404 model_not_found

```json
{
  "error": {
    "code": 404,
    "message": "The model `acme/unknown-model` does not exist or you do not have access to it.",
    "metadata": {
      "error_type": "not_found",
      "reason": "model_not_found",
      "model": "acme/unknown-model"
    }
  }
}
```

404 route_not_found

```json
{
  "error": {
    "code": 404,
    "message": "No such endpoint. Check the URL and method.",
    "metadata": {
      "error_type": "not_found",
      "reason": "route_not_found"
    }
  }
}
```

### 429

Rate limit reached. Back off and honour `Retry-After`. No `x-ratelimit-*` headers are sent.

429 rate_limited

```json
{
  "error": {
    "code": 429,
    "message": "Rate limit reached for this API key. Retry after 20 seconds.",
    "metadata": {
      "error_type": "rate_limit_exceeded",
      "reason": "rate_limited"
    }
  }
}
```

429 concurrency_limited

```json
{
  "error": {
    "code": 429,
    "message": "Too many requests are running at once for this account. Wait for some to finish, then retry.",
    "metadata": {
      "error_type": "rate_limit_exceeded",
      "reason": "concurrency_limited"
    }
  }
}
```

429 edge_rate_limited

```json
{
  "error": {
    "code": 429,
    "message": "Too many requests from this address. Retry after 60 seconds.",
    "metadata": {
      "error_type": "rate_limit_exceeded",
      "reason": "edge_rate_limited"
    }
  }
}
```

### 500

A fault on our side. Retry once, then contact support with the request id.

500 internal_error

```json
{
  "error": {
    "code": 500,
    "message": "Something went wrong on our side. Reference: 0192f0e0-7b1a-7c3e-9d4f-5a6b7c8d9e0f.",
    "metadata": {
      "error_type": "server",
      "reason": "internal_error"
    }
  }
}
```

### 503

Temporarily unavailable; refused before any model was called.

503 service_unavailable

```json
{
  "error": {
    "code": 503,
    "message": "The service is temporarily unavailable.",
    "metadata": {
      "error_type": "server",
      "reason": "service_unavailable"
    }
  }
}
```
