> For the complete documentation index, see [llms.txt](https://docs.xnomad.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xnomad.ai/xnomad.fun/agent-api/api-reference/chat-api.md).

# Chat API

* The Chat API currently do not support the following parameters:
  * **model**, **temperate**, **max\_tokens**
  * **stream** will be set to **false** ( xNomad Agents currently do not support streaming

## POST /v1/chat/completions

> Generates a model response for the given chat conversation.<br>

```json
{"openapi":"3.0.0","info":{"title":"xNomad AI API","version":"1.0.0"},"servers":[{"url":"https://core.xnomad.fun"}],"security":[{"ApiKeyAuth":[]}],"paths":{"/v1/chat/completions":{"post":{"operationId":"createChatCompletion","tags":["Chat"],"description":"Generates a model response for the given chat conversation.\n","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["messages"],"properties":{"messages":{"type":"array","description":"A list of messages comprising the conversation so far.","minItems":1,"items":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["system","user","assistant"],"description":"The role of the message author."},"content":{"type":"string","description":"The content of the message."}}}},"model":{"type":"string","description":"ID of the model to use."},"temperature":{"type":"number","description":"What sampling temperature to use, between 0 and 2.","default":1,"maximum":2,"nullable":true},"max_tokens":{"type":"integer","description":"The maximum number of tokens to generate in the chat completion.","default":1,"minimum":1,"nullable":true},"stream":{"type":"boolean","description":"If set, partial message deltas will be sent.","default":false,"nullable":true}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","required":["id","object","created","choices"],"properties":{"id":{"type":"string","description":"A unique identifier for the chat completion."},"object":{"type":"string","description":"The object type, which is always 'chat.completion'.","enum":["chat.completion"]},"created":{"type":"integer","description":"The Unix timestamp (in seconds) of when the chat completion was created."},"model":{"type":"string","description":"The model used for the chat completion."},"choices":{"type":"array","description":"A list of chat completion choices.","items":{"type":"object","required":["index","message"],"properties":{"index":{"type":"integer","description":"The index of the choice in the list."},"message":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","description":"The role of the author of this message.","enum":["assistant"]},"content":{"type":"string","description":"The content of the message."}}},"finish_reason":{"type":"string","description":"The reason the model stopped generating tokens.","enum":["stop","length","content_filter","function_call","tool_calls"]}}}},"usage":{"type":"object","description":"Usage statistics for the completion request.","properties":{"prompt_tokens":{"type":"integer","description":"Number of tokens in the prompt."},"completion_tokens":{"type":"integer","description":"Number of tokens in the generated completion."},"total_tokens":{"type":"integer","description":"Total number of tokens used in the request."}}}}}}}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.xnomad.ai/xnomad.fun/agent-api/api-reference/chat-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
