File size: 9,481 Bytes
71f8cc2
 
 
6a95a26
71f8cc2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a95a26
71f8cc2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a95a26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71f8cc2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a95a26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
openapi: 3.0.3
info:
  title: TypingMind API Documentation
  version: 1.1.0
  description: "
    <h5 class='mt-8 mb-2'><b>API Hosts:</b></h5>
    <ol class='list-decimal mt-2'>
      <li>For US instances: <code>https://api.typingmind.com</code></li>
      <li>For EU instances: <code>https://api.eu.typingmind.com</code></li>
    </ol>
    <h5 class='mt-8 mb-2'><b>How to use the API:</b></h5>
    <ol class='list-decimal mt-2'>
      <li>Generate an API key by accessing the custom instance admin page (go to Integrations > API Integration).</li>
      <li>When making a request, include the API key in the request headers as <code>X-API-KEY</code>.</li>
    </ol>
  "

servers:
  - url: https://api.typingmind.com/api/v1

tags:
  - name: Users
  - name: Characters
  - name: Chat
  - name: Chatlogs

paths:
  /users:
    post:
      operationId: addUser
      tags:
        - Users
      summary: Add a user to your chat instance
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  example: [email protected]
                tags:
                  type: array
                  items:
                    type: string
                  example: ['tag1', 'tag2']
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '401':
          description: Unauthorized (API Key is missing or invalid)

        '500':
          description: Internal Server Error

      security:
        - ApiKeyAuth: []

    get:
      operationId: getUsers
      tags:
        - Users
      summary: Get all users in your chat instance
      parameters:
        - in: query
          name: email
          schema:
            type: string
          description: Email of the user
          example: email%40example.com

      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      oneOf:
                        - $ref: '#/components/schemas/User'
        '401':
          description: Unauthorized (API Key is missing or invalid)

        '500':
          description: Internal Server Error

      security:
        - ApiKeyAuth: []

  /ai-characters:
    get:
      operationId: getCharacters
      tags:
        - Characters
      summary: Get all AI characters in your chat instance

      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      oneOf:
                        - $ref: '#/components/schemas/Character'
        '401':
          description: Unauthorized (API Key is missing or invalid)

        '500':
          description: Internal Server Error

      security:
        - ApiKeyAuth: []


  /users/{id}:
    delete:
      operationId: deleteUser
      tags:
        - Users
      summary: Remove a user from your chat instance
      parameters:
        - in: path
          name: id
          schema:
            type: integer
          required: true
          description: ID of the user
          example: 123456
      responses:
        '200':
          description: Successful

        '401':
          description: Unauthorized (API Key is missing or invalid)

        '404':
          description: User Not Found

        '500':
          description: Internal Server Error

      security:
        - ApiKeyAuth: []

    patch:
      operationId: updateUser
      tags:
        - Users
      summary: Update a user
      parameters:
        - in: path
          name: id
          schema:
            type: integer
          required: true
          description: ID of the user
          example: 123456
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                tags:
                  type: array
                  items:
                    type: string
                  example: ['tag1', 'tag2']
        required: true
      responses:
        '200':
          description: Successful

        '401':
          description: Unauthorized (API Key is missing or invalid)

        '404':
          description: User Not Found

        '500':
          description: Internal Server Error

      security:
        - ApiKeyAuth: []

  /chat/completions:
    post:
      operationId: createChatCompletions
      tags:
        - Chat
      summary: Create a model response for the given chat conversation

      requestBody:
        description: '<br>Find more information about the request body here:<br>
          <a href="https://platform.openai.com/docs/api-reference/chat/create" target="_blank">OpenAI API Reference</a><br>
          <a href="https://docs.anthropic.com/claude/reference/complete_post" target="_blank">Anthropic API Reference</a><br><br>'

        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                  enum:
                    [
                      'gpt-3.5-turbo',
                      'gpt-3.5-turbo-16k',
                      'gpt-4',
                      'gpt-4-32k',
                      'claude-2',
                      'claude-1',
                      'claude-instant-1',
                      'claude-instant-1.2',
                      'gpt-3.5-turbo-0301',
                      'gpt-4-0314',
                      'gpt-4-32k-0314',
                    ]
                stream:
                  type: boolean
                messages:
                  type: array
                  items:
                    type: object
                  description: Use for GPT models
                prompt:
                  type: string
                  description: Use for Claude models
                activatedCharacterID:
                  type: string
                  description: AI character for this completion
              required:
              - model
              - messages
              - prompt
              example:
                model: 'gpt-3.5-turbo'
                stream: true
                messages:
                  [
                    {
                      'role': 'system',
                      'content': 'You are a helpful AI assistant.',
                    },
                    { 'role': 'user', 'content': 'hi' },
                  ]

        required: true

      responses:
        '200':
          description: OK

        '401':
          description: Unauthorized (API Key is missing or invalid)

        '500':
          description: Internal Server Error

      security:
        - ApiKeyAuth: []
  /chatlogs:
    get:
      operationId: getChatlogs
      tags:
        - Chatlogs
      summary: Get chat logs in your chat instance
      parameters:
        - in: query
          name: startUnixTime
          schema:
            type: number
          description: Unix time of the start time
          example: 1640995200
        - in: query
          name: endUnixTime
          schema:
            type: number
          description: Unix time of the end time
          example: 1640995200

      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      oneOf:
                        - $ref: '#/components/schemas/Chatlog'
        '401':
          description: Unauthorized (API Key is missing or invalid)

        '500':
          description: Internal Server Error

      security:
        - ApiKeyAuth: []


components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

  schemas:
    User:
      type: object
      properties:
        id:
          type: string
          example: 123456
        email:
          type: string
          example: [email protected]
        createdAt:
          type: string
        tags:
          type: array
          items:
            type: string
          example: ['tag1', 'tag2']
    Character:
      type: object
      properties:
        id:
          type: string
        title:
          type: string
        description:
          type: string
        instruction:
          type: string
        defaultModel:
          type: string
        createdAt:
          type: string
    Chatlog:
      type: object
      properties:
        chatID:
          type: string
          example: 'U9H8EEJpLL'
        chatTitle:
          type: string
          example: 'Chat with an AI assistant'
        createdAt:
          type: string
          example: '2024-08-14T04:18:53.000Z'
        recordedAt:
          type: string
          example: '2024-08-14T04:18:53.000Z'
        conversationText:
          type: string
          example: 'User: Hello\n\nAssistant: Hi there!'