Pontos de extremidade da API REST para inferência de modelos
Use a API REST para enviar uma solicitação de preenchimento de chat para um modelo especificado, com ou sem atribuição organizacional.
Sobre a inferência do GitHub Models
Você pode usar a API REST para executar solicitações de inferência na plataforma do GitHub Models. A API requer o escopo models: read ao usar um fine-grained personal access token ou ao autenticar usando um GitHub App.
A API dá suporte para o seguinte:
- Acessar os principais modelos da OpenAI, DeepSeek, Microsoft, Llama e muito mais.
- Executar solicitações de inferência baseadas em chat com controle total sobre parâmetros de amostragem e resposta.
- Preenchimentos com streaming ou sem streaming.
- Atribuição organizacional e acompanhamento de uso.
Run an inference request attributed to an organization
This endpoint allows you to run an inference request attributed to a specific organization. You must be a member of the organization and have enabled models to use this endpoint.
The token used to authenticate must have the models: read permission if using a fine-grained PAT or GitHub App minted token.
The request body should contain the model ID and the messages for the chat completion request. The response will include either a non-streaming or streaming response based on the request parameters.
Parâmetros para "Run an inference request attributed to an organization"
| Nome, Tipo, Descrição | 
|---|
| content-typestring ObrigatórioSetting to  | 
| acceptstringSetting to  | 
| Nome, Tipo, Descrição | 
|---|
| orgstring ObrigatórioThe organization login associated with the organization to which the request is to be attributed. | 
| Nome, Tipo, Descrição | 
|---|
| api-versionstringThe API version to use. Optional, but required for some features. | 
| Nome, Tipo, Descrição | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| modelstring ObrigatórioID of the specific model to use for the request. The model ID should be in the format of {publisher}/{model_name} where "openai/gpt-4.1" is an example of a model ID. You can find supported models in the catalog/models endpoint. | ||||||||||
| messagesarray of objects ObrigatórioThe collection of context messages associated with this chat completion request. Typical usage begins with a chat message for the System role that provides instructions for the behavior of the assistant, followed by alternating messages between the User and Assistant roles. | ||||||||||
| Properties of  | 
| Nome, Tipo, Descrição | 
|---|
| rolestring ObrigatórioThe chat role associated with this message Pode ser um dos:  | 
| contentstring ObrigatórioThe content of the message | 
frequency_penalty number A value that influences the probability of generated tokens appearing based on their cumulative frequency in generated text. Positive values will make tokens less likely to appear as their frequency increases and decrease the likelihood of the model repeating the same statements verbatim. Supported range is [-2, 2].
max_tokens integer The maximum number of tokens to generate in the completion. The token count of your prompt plus max_tokens cannot exceed the model's context length. For example, if your prompt is 100 tokens and you set max_tokens to 50, the API will return a completion with a maximum of 50 tokens.
modalities array of strings The modalities that the model is allowed to use for the chat completions response. The default modality is text. Indicating an unsupported modality combination results in a 422 error.
Supported values are: text, audio
presence_penalty number A value that influences the probability of generated tokens appearing based on their existing presence in generated text. Positive values will make tokens less likely to appear when they already exist and increase the model's likelihood to output new tokens. Supported range is [-2, 2].
response_format object The desired format for the response.
Can be one of these objects:
| Nome, Tipo, Descrição | |||
|---|---|---|---|
| Objectobject | |||
| Properties of  | 
| Nome, Tipo, Descrição | 
|---|
| typestringPode ser um dos:  | 
Schema for structured JSON response object ObrigatórioProperties of Schema for structured JSON response
| Nome, Tipo, Descrição | 
|---|
| typestring ObrigatórioThe type of the response. Valor:  | 
| json_schemaobject ObrigatórioThe JSON schema for the response. | 
seed integer If specified, the system will make a best effort to sample deterministically such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed.
stream boolean A value indicating whether chat completions should be streamed for this request.
Padrão: false
stream_options object Whether to include usage information in the response. Requires stream to be set to true.
Properties of stream_options
| Nome, Tipo, Descrição | 
|---|
| include_usagebooleanWhether to include usage information in the response. Padrão:  | 
stop array of strings A collection of textual sequences that will end completion generation.
temperature number The sampling temperature to use that controls the apparent creativity of generated completions. Higher values will make output more random while lower values will make results more focused and deterministic. It is not recommended to modify temperature and top_p for the same completion request as the interaction of these two settings is difficult to predict. Supported range is [0, 1]. Decimal values are supported.
tool_choice string If specified, the model will configure which of the provided tools it can use for the chat completions response.
Pode ser um dos: auto, required, none 
tools array of objects A list of tools the model may request to call. Currently, only functions are supported as a tool. The model may respond with a function call request and provide the input arguments in JSON format for that function.
Properties of tools
| Nome, Tipo, Descrição | ||||
|---|---|---|---|---|
| functionobject | ||||
| Properties of  | 
| Nome, Tipo, Descrição | 
|---|
| namestringThe name of the function to be called. | 
| descriptionstringA description of what the function does. The model will use this description when selecting the function and interpreting its parameters. | 
| parametersThe parameters the function accepts, described as a JSON Schema object. | 
type string Valor: function 
top_p number An alternative to sampling with temperature called nucleus sampling. This value causes the model to consider the results of tokens with the provided probability mass. As an example, a value of 0.15 will cause only the tokens comprising the top 15% of probability mass to be considered. It is not recommended to modify temperature and top_p for the same request as the interaction of these two settings is difficult to predict. Supported range is [0, 1]. Decimal values are supported.
Códigos de status de resposta HTTP para "Run an inference request attributed to an organization"
| Código de status | Descrição | 
|---|---|
| 200 | OK | 
Exemplos de código para "Run an inference request attributed to an organization"
Exemplo de solicitação
curl -L \
  -X POST \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  -H "Content-Type: application/json" \
  https://models.github.ai/orgs/ORG/inference/chat/completions \
  -d '{"model":"openai/gpt-4.1","messages":[{"role":"user","content":"What is the capital of France?"}]}'Resposta
Status: 200{
  "choices": [
    {
      "message": {
        "content": "The capital of France is Paris.",
        "role": "assistant"
      }
    }
  ]
}Run an inference request
This endpoint allows you to run an inference request. The token used to authenticate must have the models: read permission if using a fine-grained PAT or GitHub App minted token.
The request body should contain the model ID and
the messages for the chat completion request. The response will include either a non-streaming or streaming response based on the request parameters.
Parâmetros para "Run an inference request"
| Nome, Tipo, Descrição | 
|---|
| content-typestring ObrigatórioSetting to  | 
| acceptstringSetting to  | 
| Nome, Tipo, Descrição | 
|---|
| api-versionstringThe API version to use. Optional, but required for some features. | 
| Nome, Tipo, Descrição | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| modelstring ObrigatórioID of the specific model to use for the request. The model ID should be in the format of {publisher}/{model_name} where "openai/gpt-4.1" is an example of a model ID. You can find supported models in the catalog/models endpoint. | ||||||||||
| messagesarray of objects ObrigatórioThe collection of context messages associated with this chat completion request. Typical usage begins with a chat message for the System role that provides instructions for the behavior of the assistant, followed by alternating messages between the User and Assistant roles. | ||||||||||
| Properties of  | 
| Nome, Tipo, Descrição | 
|---|
| rolestring ObrigatórioThe chat role associated with this message Pode ser um dos:  | 
| contentstring ObrigatórioThe content of the message | 
frequency_penalty number A value that influences the probability of generated tokens appearing based on their cumulative frequency in generated text. Positive values will make tokens less likely to appear as their frequency increases and decrease the likelihood of the model repeating the same statements verbatim. Supported range is [-2, 2].
max_tokens integer The maximum number of tokens to generate in the completion. The token count of your prompt plus max_tokens cannot exceed the model's context length. For example, if your prompt is 100 tokens and you set max_tokens to 50, the API will return a completion with a maximum of 50 tokens.
modalities array of strings The modalities that the model is allowed to use for the chat completions response. The default modality is text. Indicating an unsupported modality combination results in a 422 error.
Supported values are: text, audio
presence_penalty number A value that influences the probability of generated tokens appearing based on their existing presence in generated text. Positive values will make tokens less likely to appear when they already exist and increase the model's likelihood to output new tokens. Supported range is [-2, 2].
response_format object The desired format for the response.
Can be one of these objects:
| Nome, Tipo, Descrição | |||
|---|---|---|---|
| Objectobject | |||
| Properties of  | 
| Nome, Tipo, Descrição | 
|---|
| typestringPode ser um dos:  | 
Schema for structured JSON response object ObrigatórioProperties of Schema for structured JSON response
| Nome, Tipo, Descrição | 
|---|
| typestring ObrigatórioThe type of the response. Valor:  | 
| json_schemaobject ObrigatórioThe JSON schema for the response. | 
seed integer If specified, the system will make a best effort to sample deterministically such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed.
stream boolean A value indicating whether chat completions should be streamed for this request.
Padrão: false
stream_options object Whether to include usage information in the response. Requires stream to be set to true.
Properties of stream_options
| Nome, Tipo, Descrição | 
|---|
| include_usagebooleanWhether to include usage information in the response. Padrão:  | 
stop array of strings A collection of textual sequences that will end completion generation.
temperature number The sampling temperature to use that controls the apparent creativity of generated completions. Higher values will make output more random while lower values will make results more focused and deterministic. It is not recommended to modify temperature and top_p for the same completion request as the interaction of these two settings is difficult to predict. Supported range is [0, 1]. Decimal values are supported.
tool_choice string If specified, the model will configure which of the provided tools it can use for the chat completions response.
Pode ser um dos: auto, required, none 
tools array of objects A list of tools the model may request to call. Currently, only functions are supported as a tool. The model may respond with a function call request and provide the input arguments in JSON format for that function.
Properties of tools
| Nome, Tipo, Descrição | ||||
|---|---|---|---|---|
| functionobject | ||||
| Properties of  | 
| Nome, Tipo, Descrição | 
|---|
| namestringThe name of the function to be called. | 
| descriptionstringA description of what the function does. The model will use this description when selecting the function and interpreting its parameters. | 
| parametersThe parameters the function accepts, described as a JSON Schema object. | 
type string Valor: function 
top_p number An alternative to sampling with temperature called nucleus sampling. This value causes the model to consider the results of tokens with the provided probability mass. As an example, a value of 0.15 will cause only the tokens comprising the top 15% of probability mass to be considered. It is not recommended to modify temperature and top_p for the same request as the interaction of these two settings is difficult to predict. Supported range is [0, 1]. Decimal values are supported.
Códigos de status de resposta HTTP para "Run an inference request"
| Código de status | Descrição | 
|---|---|
| 200 | OK | 
Exemplos de código para "Run an inference request"
Exemplo de solicitação
curl -L \
  -X POST \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  -H "Content-Type: application/json" \
  https://models.github.ai/inference/chat/completions \
  -d '{"model":"openai/gpt-4.1","messages":[{"role":"user","content":"What is the capital of France?"}]}'Resposta
Status: 200{
  "choices": [
    {
      "message": {
        "content": "The capital of France is Paris.",
        "role": "assistant"
      }
    }
  ]
}