> For the complete documentation index, see [llms.txt](https://docs.uptiq.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uptiq.ai/platform/platform-resources/agent-executor/openai-compatible-client.md). Agents can also search and read this documentation through its [MCP server](https://docs.uptiq.ai/~gitbook/mcp).

# OpenAI-compatible client

Call an agent or an assistant from a tool or SDK that sends OpenAI-compatible chat or response requests.

Use this connection to call an agent from a tool or SDK that sends OpenAI-compatible chat or response requests. Use the connection details for the agent's own executor version; don't substitute unrelated gateway credentials or settings.

## Prepare the connection

1. Choose the agent and the API path for its executor version.
2. Set up a supported credential:
   * an agent API key and secret
   * an access token, within its [restrictions](https://docs.uptiq.ai/platform/platform-resources/agent-executor/secure-access.md#access-token-restrictions)
   * a service account, which is the only way to call an assistant
3. For an assistant, include the project in the request.
4. Send a simple request before you add conversation history, files or streaming.
5. Check the reply and any error. Keep the request ID if you need support.

Assistants can be called only with a service account. By default, the agent runs its published version. The executor version and a saved version of the agent are different things; see [Runtime & Versioning](https://docs.uptiq.ai/platform/console/agent-builder/build/runtime-and-versioning.md#draft-versions-and-executor-versions).

## Send history and per-request instructions

* A chat-style request can include earlier messages, and the agent uses them as conversation history.
* System or developer messages from the caller apply to that reply only, and can't override the agent's own instructions.
* When you continue from a previous response, earlier messages sent again with the request are ignored, because the conversation is already available. New per-request instructions still apply.
* Personal information in the history and instruction messages follows the agent's masking settings. With masking off, it isn't masked.

## Replies and usage

* Replies come back as readable text, including answers with tables or charts. Both normal and streamed replies are supported.
* Background responses start queued and can be checked later for completion. Access tokens can't retrieve them.
* Completed responses report token usage, including cached input tokens and reasoning tokens. For a streamed response, ask for usage to receive it at the end.
* A stream ends cleanly if the agent pauses to ask a question.
* Existing Agent SDK and trigger responses keep their fields; they don't gain the same usage information.

## Credential scope

* An agent API key can see only its own agent.
* Access tokens can't list models.
* With a service account and a project, the model list includes shared agents and the assistants available through that connection.
* A missing, unknown or wrong key or secret, or an invalid or expired service account token, returns `invalid_api_key` with `authentication_error`.
* Asking for an agent you can't reach returns `model_not_found`, with a message that the model doesn't exist or you don't have access to it.

## Add files and images

| Rule                                            | Limit or behavior                                                                |
| ----------------------------------------------- | -------------------------------------------------------------------------------- |
| Attachments per request                         | At most 10 files and images combined                                             |
| Files and images sent within the request        | 5 MB each. Upload larger files through the files endpoint.                       |
| Linked images                                   | 5 MB each                                                                        |
| File types                                      | Must be supported by the agent                                                   |
| No file type given                              | Worked out from the file name or content where possible; rejected if it can't be |
| One attachment rejected in a multi-file request | None of that request's files are saved                                           |

A reference to a missing file returns a file-not-found error, and an unsupported type returns an error that the agent doesn't support the file type. Correct the request before you send its attachments again.

## Tool approvals

Tool approvals can't be given through the OpenAI-compatible API. If a tool needs approval, a non-streamed request returns `tool_approval_unsupported`, and a streamed one reports it in the stream. The OpenAI SDK gets the error without running the agent again. Don't keep resending the same action expecting the approval to go through on this connection.

***

{% columns %}
{% column width="83.33333333333334%" %}

<p align="right"><em>Maintained by</em> <mark style="color:green;">Abhishek Paul</mark><br><code>AI-assisted, human-approved</code></p>
{% endcolumn %}

{% column width="16.666666666666664%" %}

<div align="left"><img src="https://1326225582-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0qmgQjJ5aArDTj2ACFHG%2Fuploads%2Fgit-blob-d034645b4f8f8ee661985f5306b60ded3289653c%2Fmaintainer-abhishek-paul.png?alt=media" alt="" width="60"></div>
{% endcolumn %}
{% endcolumns %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.uptiq.ai/platform/platform-resources/agent-executor/openai-compatible-client.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
