Commit 543776

2024-08-24 09:47:16 admin: -/-
chat api.md ..
@@ 1,12 1,16 @@
# chatapi.ai-now.space API Documentation
- This API provides access to a variety of large language models (LLMs) for chat completions, token counting, and moderation.
+ This document provides a comprehensive overview of the chatapi.ai-now.space API, detailing its functionalities, endpoints, and usage instructions.
+
+ ## Overview
+
+ chatapi.ai-now.space is a proxy API that provides access to various large language models (LLMs) for chat completions and other AI-related tasks. It offers a unified interface for interacting with different models, simplifying the development process for users.
## Authentication
- You need an API key to use this API. To obtain an API key, please contact `[email protected]`.
+ All API requests require an API key for authentication. To obtain an API key, please contact [email protected].
- Once you have an API key, include it in the `Authorization` header of your requests as a Bearer token:
+ The API key should be included in the `Authorization` header of each request using the `Bearer` scheme:
```
Authorization: Bearer YOUR_API_KEY
@@ 14,11 18,9 @@
## Endpoints
- ### /models
-
- **Method:** GET
+ ### `/models`
- **Description:** Returns a list of available models with their associated input and output costs.
+ **GET** - Retrieves a list of available models.
**Response:**
@@ 26,54 28,67 @@
{
"data": [
{
- "id": "Claude 3.5 Sonnet",
- "inputCost": 0.002,
- "outputCost": 0.003
- },
- {
- "id": "GPT-4 Turbo",
- "inputCost": 0.03,
- "outputCost": 0.06
+ "id": 1,
+ "name": "Model A",
+ "contextWindow": 2048,
+ "inputCostPer1kTokens": 0.001,
+ "outputCostPer1kTokens": 0.002,
+ "quality": "high",
+ "medianPrice": 0.05,
+ "outputTokensPerSecond": 10,
+ "latencyToFirstChunk": 500,
+ "average": 85,
+ "multiChoiceQs": 90,
+ "reasoning": 80,
+ "pythonCoding": 75,
+ "futureCapabilities": 70,
+ "gradeSchoolMath": 95,
+ "mathProblems": 80,
+ "arenaScore": 75,
+ "confidenceInterval": 90,
+ "votes": 100,
+ "organization": "Organization A",
+ "license": "MIT",
+ "knowledgeCutoff": "2023-01-01",
+ "working": true
},
// ... other models
]
}
```
+ ### [Full list of models is available here](https://wiki.ai-now.space/Models)
- ### /chat/completions
+ **Example:**
- **Method:** POST
+ ```bash
+ curl -H "Authorization: Bearer YOUR_API_KEY" https://chatapi.ai-now.space/models
+ ```
+
+ ### `/chat/completions`
- **Description:** Generates chat completions using the specified model.
+ **POST** - Generates chat completions using the specified model.
- #### Request Body
+ **Request Body:**
```json
{
- "model": "MODEL_NAME", // See the list of supported models below
+ "model": "Model A",
"messages": [
- {
- "role": "system",
- "content": "You are a helpful assistant."
- },
- {
- "role": "user",
- "content": "What is the capital of France?"
- }
+ { "role": "user", "content": "What is the capital of France?" }
],
- "stream": true/false, // Optional, defaults to false
- // ... other parameters (see model-specific documentation)
+ "stream": false, // Optional, defaults to false
+ // ... other parameters (see OpenAI's Chat Completion API documentation)
}
```
- #### Non-Streaming Response
+ **Response (Non-Streaming):**
```json
{
- "id": "chatcmpl-...",
+ "id": "chatcmpl-XXXXXXXXXXXXXXXXX",
"object": "chat.completion",
- "created": 1677652288,
- "model": "MODEL_NAME",
+ "created": 1678886384,
+ "model": "Model A",
"choices": [
{
"index": 0,
@@ 84,43 99,70 @@
"finish_reason": "stop"
}
],
- "input_tokens": ...,
- "output_tokens": ...,
- "input_tokens_cost": ...,
- "output_tokens_cost": ...,
- "total_tokens_cost": ...,
- "total_time_taken": ...,
- "tokens_per_second": ...
+ "input_tokens": 7,
+ "output_tokens": 6,
+ "input_tokens_cost": 0.000007,
+ "output_tokens_cost": 0.000012,
+ "total_tokens_cost": 0.000019,
+ "total_time_taken": 123,
+ "tokens_per_second": 0.1057
}
```
- #### Streaming Response
+ **Response (Streaming):**
```text
- data: {"id": "chatcmpl-...", "object": "chat.completion.chunk", "created": 1677652288, "model": "MODEL_NAME", "choices": [{"index": 0, "delta": {"content": "The"}, "finish_reason": null}]}
+ data: {"id": "chatcmpl-XXXXXXXXXXXXXXXXX", "object": "chat.completion.chunk", "created": 1678886384, "model": "Model A", "choices": [{"index": 0, "delta": {"content": "The"}, "finish_reason": null}]}
+
+ data: {"id": "chatcmpl-XXXXXXXXXXXXXXXXX", "object": "chat.completion.chunk", "created": 1678886384, "model": "Model A", "choices": [{"index": 0, "delta": {"content": " capital"}, "finish_reason": null}]}
+
+ data: {"id": "chatcmpl-XXXXXXXXXXXXXXXXX", "object": "chat.completion.chunk", "created": 1678886384, "model": "Model A", "choices": [{"index": 0, "delta": {"content": " of"}, "finish_reason": null}]}
+
+ data: {"id": "chatcmpl-XXXXXXXXXXXXXXXXX", "object": "chat.completion.chunk", "created": 1678886384, "model": "Model A", "choices": [{"index": 0, "delta": {"content": " France"}, "finish_reason": null}]}
- data: {"id": "chatcmpl-...", "object": "chat.completion.chunk", "created": 1677652288, "model": "MODEL_NAME", "choices": [{"index": 0, "delta": {"content": " capital"}, "finish_reason": null}]}
+ data: {"id": "chatcmpl-XXXXXXXXXXXXXXXXX", "object": "chat.completion.chunk", "created": 1678886384, "model": "Model A", "choices": [{"index": 0, "delta": {"content": " is"}, "finish_reason": null}]}
- data: {"id": "chatcmpl-...", "object": "chat.completion.chunk", "created": 1677652288, "model": "MODEL_NAME", "choices": [{"index": 0, "delta": {"content": " of"}, "finish_reason": null}]}
+ data: {"id": "chatcmpl-XXXXXXXXXXXXXXXXX", "object": "chat.completion.chunk", "created": 1678886384, "model": "Model A", "choices": [{"index": 0, "delta": {"content": " Paris."}, "finish_reason": null}]}
- // ... more chunks
+ data: {"id": "chatcmpl-XXXXXXXXXXXXXXXXX", "object": "chat.completion.chunk", "created": 1678886384, "model": "Model A", "choices": [{"index": 0, "delta": {}, "finish_reason": "stop"}]}
- data: {"id": "chatcmpl-...", "object": "chat.completion.chunk", "created": 1677652288, "model": "MODEL_NAME", "choices": [{"index": 0, "delta": {"content": " is Paris."}, "finish_reason": "stop"}]}
+ data: {"input_tokens": 7, "output_tokens": 6, "input_tokens_cost": 0.000007, "output_tokens_cost": 0.000012, "total_tokens_cost": 0.000019, "total_time_taken": 123, "tokens_per_second": 0.1057}
- data: {"input_tokens": ..., "output_tokens": ..., "input_tokens_cost": ..., "output_tokens_cost": ..., "total_tokens_cost": ..., "total_time_taken": ..., "tokens_per_second": ..., "time_to_first_data": ...}
+ data: [DONE]
+ ```
+
+ **Example (Non-Streaming):**
+
+ ```bash
+ curl -X POST -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{
+ "model": "Model A",
+ "messages": [
+ { "role": "user", "content": "What is the capital of France?" }
+ ]
+ }' https://chatapi.ai-now.space/chat/completions
```
- ### /tokens
+ **Example (Streaming):**
+
+ ```bash
+ curl -X POST -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{
+ "model": "Model A",
+ "messages": [
+ { "role": "user", "content": "What is the capital of France?" }
+ ],
+ "stream": true
+ }' https://chatapi.ai-now.space/chat/completions
+ ```
- **Method:** POST
+ ### `/tokens`
- **Description:** Counts the number of tokens in a given text.
+ **POST** - Counts the number of tokens in a given text.
**Request Body:**
```json
{
- "text": "Your text here"
+ "text": "This is a test sentence."
}
```
@@ 128,15 170,21 @@
```json
{
- "tokens": 123
+ "tokens": 6
}
```
- ### /credits
+ **Example:**
- **Method:** GET
+ ```bash
+ curl -X POST -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{
+ "text": "This is a test sentence."
+ }' https://chatapi.ai-now.space/tokens
+ ```
+
+ ### `/credits`
- **Description:** Returns the remaining credits for your API key.
+ **GET** - Retrieves the remaining credits for the API key.
**Response:**
@@ 146,17 194,21 @@
}
```
- ### /moderate
+ **Example:**
- **Method:** POST
+ ```bash
+ curl -H "Authorization: Bearer YOUR_API_KEY" https://chatapi.ai-now.space/credits
+ ```
- **Description:** Moderates the given input text using OpenAI's moderation API.
+ ### `/moderate`
+
+ **POST** - Moderates the given input text using OpenAI's moderation API.
**Request Body:**
```json
{
- "input": "Your text here"
+ "input": "This is a test sentence."
}
```
@@ 164,17 216,27 @@
```json
{
+ "id": "modr-XXXXXXXXXXXXXXXXX",
+ "model": "text-moderation-latest",
"results": [
{
"categories": {
"hate": false,
"hate/threatening": false,
- // ... other categories
+ "self-harm": false,
+ "sexual": false,
+ "sexual/minors": false,
+ "violence": false,
+ "violence/graphic": false
},
"category_scores": {
"hate": 0.0000000000000000,
"hate/threatening": 0.0000000000000000,
- // ... other category scores
+ "self-harm": 0.0000000000000000,
+ "sexual": 0.0000000000000000,
+ "sexual/minors": 0.0000000000000000,
+ "violence": 0.0000000000000000,
+ "violence/graphic": 0.0000000000000000
},
"flagged": false
}
@@ 182,7 244,31 @@
}
```
- ## Models [Full list of models is available here](https://wiki.ai-now.space/Models)
+ **Example:**
+
+ ```bash
+ curl -X POST -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{
+ "input": "This is a test sentence."
+ }' https://chatapi.ai-now.space/moderate
+ ```
+
+ ## Rate Limiting
+
+ The API is rate limited to 100 requests per minute per API key. Exceeding this limit will result in a `429 Too Many Requests` error.
+
+ ## Error Handling
+
+ The API uses standard HTTP status codes to indicate the success or failure of a request. Common error codes include:
+
+ * **400 Bad Request:** The request was malformed or invalid.
+ * **401 Unauthorized:** The API key was missing or invalid.
+ * **429 Too Many Requests:** The rate limit has been exceeded.
+ * **500 Internal Server Error:** An unexpected error occurred on the server.
+
+ ## Contact
+
+ For any questions or issues, please contact [email protected].
+
## Usage Examples
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9