PetstoreAPI Docs
Modern Petstore APIClassic Petstore APIBlog
Modern Petstore APIClassic Petstore APIBlog
  1. Chat
  • Modern Pet Store API: A New Gold Standard for OpenAPI
  • Pet
    • Get Pet
      GET
    • Update Pet
      PUT
    • Delete Pet
      DELETE
    • Create Pet
      POST
    • List Pets
      GET
    • Upload Pet Image
      POST
  • Chat
    • Create Chat Completion
      POST
  • Payments
    • Pay Order
      POST
  • Store
    • List Inventory
      GET
    • Create Order
      POST
    • Get Order
      GET
    • Delete Order
      DELETE
    • Callback Example
      POST
  • User
    • Create User
      POST
    • Update User
      PUT
    • Get User
      GET
    • Delete User
      DELETE
    • Login
      POST
    • Logout
      POST
  • Webhooks
    • Pet Adopted Event
    • New Pet Available Event
  • Schemas
    • Pet
    • PetCollection
    • User
    • OrderPayment
    • Bank Card
    • Bank Account
    • Category
    • Links
    • Order
    • ApiResponse
    • Tag
    • Error
Modern Petstore APIClassic Petstore APIBlog
Modern Petstore APIClassic Petstore APIBlog
  1. Chat

Create Chat Completion

POST
/chat/completions
Creates a model response for a chat conversation with the Pet Adoption Advisor AI. Supports streaming responses using Server-Sent Events (SSE).

Pet Adoption Advisor#

Our AI assistant helps users:
Get personalized pet recommendations
Learn about pet care and adoption process
Answer questions about specific pets
Provide breed information and compatibility advice

Streaming Mode#

When stream: true, the response is sent as Server-Sent Events (SSE), with each token delivered incrementally. This provides a better user experience for longer responses.

Stream Format#

Each chunk is sent as:
data: {"id":"chatcmpl_abc","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"},"index":0}]}
The stream ends with:
data: [DONE]

Non-Streaming Mode#

When stream: false or omitted, returns a complete response object.

Request

Authorization
OAuth 2.0
Authorization Code
deviceCode
Add the parameter
Authorization
to Headers
,whose value is to concatenate the Token after the Bearer.
Example:
Authorization: Bearer ********************
Authorize URL: https://auth.petstoreapi.com/authorize
Token URL: https://auth.petstoreapi.com/token
Refresh URL: https://auth.petstoreapi.com/refresh
or
JWT Bearer
Add the parameter
Authorization
to Headers
Example:
Authorization: ********************
or
Body Params application/jsonRequired

Examples

Responses

🟢201
application/json
Successful response. Format depends on the stream parameter.
Headers

Body

🟠400BadRequest
🟠401Unauthorized
🟠429TooManyRequests
Request Request Example
Shell
JavaScript
Java
Swift
cURL (Non-Streaming)
curl -X POST 'https://api.petstoreapi.com/v1/chat/completions' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "messages": [
      {
        "role": "user",
        "content": "What should I know before adopting a cat?"
      }
    ],
    "model": "pet-advisor-1",
    "stream": false
  }'
Response Response Example
201 - Complete chat response
{
    "id": "chatcmpl_abc123",
    "object": "chat.completion",
    "created": 1702648800,
    "model": "pet-advisor-1",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "Before adopting a cat, consider these important factors:\n\n1. **Time Commitment**: Cats can live 15-20 years\n2. **Space**: Ensure you have adequate living space\n3. **Allergies**: Check if anyone in your household has cat allergies\n4. **Costs**: Budget for food, litter, vet care, and supplies\n5. **Lifestyle**: Consider if your schedule allows for proper care\n\nWould you like recommendations for cats currently available for adoption?"
            },
            "finishReason": "stop"
        }
    ],
    "usage": {
        "promptTokens": 15,
        "completionTokens": 89,
        "totalTokens": 104
    }
}
Modified at 2025-12-17 08:25:04
Previous
Upload Pet Image
Next
Pay Order
Built with