Skip to main content
Glama
models.py45.6 kB
# generated by fastapi-codegen: # filename: openapi.yaml # timestamp: 2025-06-29T07:51:02+00:00 from __future__ import annotations from enum import Enum from typing import Any, Dict, List, Optional, Union from pydantic import BaseModel, ConfigDict, Field, RootModel, confloat, conint, constr class Role(Enum): system = 'system' user = 'user' assistant = 'assistant' class ChatCompletionRequestMessage(BaseModel): content: str = Field(..., description='The contents of the message') name: Optional[str] = Field( None, description='The name of the user in a multi-user chat' ) role: Role = Field(..., description='The role of the author of this message.') class ChatCompletionResponseMessage(BaseModel): content: str = Field(..., description='The contents of the message') role: Role = Field(..., description='The role of the author of this message.') class ExampleItem(RootModel[constr(min_length=1)]): root: constr(min_length=1) class Example(RootModel[List[ExampleItem]]): root: List[ExampleItem] class CreateAnswerRequest(BaseModel): model_config = ConfigDict( extra='forbid', ) documents: Optional[List[str]] = Field( None, description='List of documents from which the answer for the input `question` should be derived. If this is an empty list, the question will be answered based on the question-answer examples.\n\nYou should specify either `documents` or a `file`, but not both.\n', examples=[ "['Japan is an island country in East Asia, located in the northwest Pacific Ocean.', 'Tokyo is the capital and most populous prefecture of Japan.']" ], max_length=200, ) examples: List[Example] = Field( ..., description="List of (question, answer) pairs that will help steer the model towards the tone and answer format you'd like. We recommend adding 2 to 3 examples.", examples=[ "[['What is the capital of Canada?', 'Ottawa'], ['Which province is Ottawa in?', 'Ontario']]" ], max_length=200, min_length=1, ) examples_context: str = Field( ..., description='A text snippet containing the contextual information used to generate the answers for the `examples` you provide.', examples=[ "Ottawa, Canada's capital, is located in the east of southern Ontario, near the city of Montréal and the U.S. border." ], ) expand: Optional[List] = Field( [], description='If an object name is in the list, we provide the full information of the object; otherwise, we only provide the object ID. Currently we support `completion` and `file` objects for expansion.', ) file: Optional[str] = Field( None, description='The ID of an uploaded file that contains documents to search over. See [upload file](/docs/api-reference/files/upload) for how to upload a file of the desired format and purpose.\n\nYou should specify either `documents` or a `file`, but not both.\n', ) logit_bias: Optional[Dict[str, Any]] = Field( None, description='Modify the likelihood of specified tokens appearing in the completion.\n\nAccepts a json object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this [tokenizer tool](/tokenizer?view=bpe) (which works for both GPT-2 and GPT-3) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.\n\nAs an example, you can pass `{"50256": -100}` to prevent the <|endoftext|> token from being generated.\n', ) logprobs: Optional[conint(ge=0, le=5)] = Field( None, description='Include the log probabilities on the `logprobs` most likely tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response.\n\nThe maximum value for `logprobs` is 5. If you need more than this, please contact us through our [Help center](https://help.openai.com) and describe your use case.\n\nWhen `logprobs` is set, `completion` will be automatically added into `expand` to get the logprobs.\n', ) max_rerank: Optional[int] = Field( 200, description='The maximum number of documents to be ranked by [Search](/docs/api-reference/searches/create) when using `file`. Setting it to a higher value leads to improved accuracy but with increased latency and cost.', ) max_tokens: Optional[int] = Field( 16, description='The maximum number of tokens allowed for the generated answer' ) model: str = Field( ..., description='ID of the model to use for completion. You can select one of `ada`, `babbage`, `curie`, or `davinci`.', ) n: Optional[conint(ge=1, le=10)] = Field( 1, description='How many answers to generate for each question.' ) question: constr(min_length=1) = Field( ..., description='Question to get answered.', examples=['What is the capital of Japan?'], ) return_metadata: Optional[bool] = Field( False, description='A special boolean flag for showing metadata. If set to `true`, each document entry in the returned JSON will contain a "metadata" field.\n\nThis flag only takes effect when `file` is set.\n', ) return_prompt: Optional[bool] = Field( False, description='If set to `true`, the returned JSON will include a "prompt" field containing the final prompt that was used to request a completion. This is mainly useful for debugging purposes.', ) search_model: Optional[str] = Field( 'ada', description='ID of the model to use for [Search](/docs/api-reference/searches/create). You can select one of `ada`, `babbage`, `curie`, or `davinci`.', ) stop: Optional[Union[str, List[str]]] = Field( None, description='Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.\n', ) temperature: Optional[float] = Field( 0, description='What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.', ) user: Optional[str] = Field( None, description='A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).\n', examples=['user-1234'], ) class SelectedDocument(BaseModel): document: Optional[int] = None text: Optional[str] = None class CreateAnswerResponse(BaseModel): answers: Optional[List[str]] = None completion: Optional[str] = None model: Optional[str] = None object: Optional[str] = None search_model: Optional[str] = None selected_documents: Optional[List[SelectedDocument]] = None class CreateChatCompletionRequest(BaseModel): frequency_penalty: Optional[confloat(ge=-2.0, le=2.0)] = Field( 0, description="Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.\n\n[See more information about frequency and presence penalties.](/docs/api-reference/parameter-details)\n", ) logit_bias: Optional[Dict[str, Any]] = Field( None, description='Modify the likelihood of specified tokens appearing in the completion.\n\nAccepts a json object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.\n', ) max_tokens: Optional[int] = Field( 'inf', description='The maximum number of tokens allowed for the generated answer. By default, the number of tokens the model can return will be (4096 - prompt tokens).\n', ) messages: List[ChatCompletionRequestMessage] = Field( ..., description='The messages to generate chat completions for, in the [chat format](/docs/guides/chat/introduction).', min_length=1, ) model: str = Field( ..., description='ID of the model to use. Currently, only `gpt-3.5-turbo` and `gpt-3.5-turbo-0301` are supported.', ) n: Optional[conint(ge=1, le=128)] = Field( 1, description='How many chat completion choices to generate for each input message.', examples=[1], ) presence_penalty: Optional[confloat(ge=-2.0, le=2.0)] = Field( 0, description="Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.\n\n[See more information about frequency and presence penalties.](/docs/api-reference/parameter-details)\n", ) stop: Optional[Union[str, List[str]]] = Field( None, description='Up to 4 sequences where the API will stop generating further tokens.\n', ) stream: Optional[bool] = Field( False, description='If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message.\n', ) temperature: Optional[confloat(ge=0.0, le=2.0)] = Field( 1, description='What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\n\nWe generally recommend altering this or `top_p` but not both.\n', examples=[1], ) top_p: Optional[confloat(ge=0.0, le=1.0)] = Field( 1, description='An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nWe generally recommend altering this or `temperature` but not both.\n', examples=[1], ) user: Optional[str] = Field( None, description='A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).\n', examples=['user-1234'], ) class Choice(BaseModel): finish_reason: Optional[str] = None index: Optional[int] = None message: Optional[ChatCompletionResponseMessage] = None class Usage(BaseModel): completion_tokens: int prompt_tokens: int total_tokens: int class CreateChatCompletionResponse(BaseModel): choices: List[Choice] created: int id: str model: str object: str usage: Optional[Usage] = None class Example1Item(RootModel[constr(min_length=1)]): root: constr(min_length=1) class Example1(RootModel[List[Example1Item]]): root: List[Example1Item] class CreateClassificationRequest(BaseModel): model_config = ConfigDict( extra='forbid', ) examples: Optional[List[Example1]] = Field( None, description='A list of examples with labels, in the following format:\n\n`[["The movie is so interesting.", "Positive"], ["It is quite boring.", "Negative"], ...]`\n\nAll the label strings will be normalized to be capitalized.\n\nYou should specify either `examples` or `file`, but not both.\n', examples=[ "[['Do not see this film.', 'Negative'], ['Smart, provocative and blisteringly funny.', 'Positive']]" ], max_length=200, min_length=2, ) expand: Optional[List] = Field( [], description='If an object name is in the list, we provide the full information of the object; otherwise, we only provide the object ID. Currently we support `completion` and `file` objects for expansion.', ) file: Optional[str] = Field( None, description='The ID of the uploaded file that contains training examples. See [upload file](/docs/api-reference/files/upload) for how to upload a file of the desired format and purpose.\n\nYou should specify either `examples` or `file`, but not both.\n', ) labels: Optional[List[str]] = Field( None, description='The set of categories being classified. If not specified, candidate labels will be automatically collected from the examples you provide. All the label strings will be normalized to be capitalized.', examples=[['Positive', 'Negative']], max_length=200, min_length=2, ) logit_bias: Optional[Dict[str, Any]] = Field( None, description='Modify the likelihood of specified tokens appearing in the completion.\n\nAccepts a json object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this [tokenizer tool](/tokenizer?view=bpe) (which works for both GPT-2 and GPT-3) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.\n\nAs an example, you can pass `{"50256": -100}` to prevent the <|endoftext|> token from being generated.\n', ) logprobs: Optional[conint(ge=0, le=5)] = Field( None, description='Include the log probabilities on the `logprobs` most likely tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response.\n\nThe maximum value for `logprobs` is 5. If you need more than this, please contact us through our [Help center](https://help.openai.com) and describe your use case.\n\nWhen `logprobs` is set, `completion` will be automatically added into `expand` to get the logprobs.\n', ) max_examples: Optional[int] = Field( 200, description='The maximum number of examples to be ranked by [Search](/docs/api-reference/searches/create) when using `file`. Setting it to a higher value leads to improved accuracy but with increased latency and cost.', ) model: str = Field( ..., description='ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them.', ) query: constr(min_length=1) = Field( ..., description='Query to be classified.', examples=['The plot is not very attractive.'], ) return_metadata: Optional[bool] = Field( False, description='A special boolean flag for showing metadata. If set to `true`, each document entry in the returned JSON will contain a "metadata" field.\n\nThis flag only takes effect when `file` is set.\n', ) return_prompt: Optional[bool] = Field( False, description='If set to `true`, the returned JSON will include a "prompt" field containing the final prompt that was used to request a completion. This is mainly useful for debugging purposes.', ) search_model: Optional[str] = Field( 'ada', description='ID of the model to use for [Search](/docs/api-reference/searches/create). You can select one of `ada`, `babbage`, `curie`, or `davinci`.', ) temperature: Optional[confloat(ge=0.0, le=2.0)] = Field( 0, description='What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.', examples=[0], ) user: Optional[str] = Field( None, description='A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).\n', examples=['user-1234'], ) class SelectedExample(BaseModel): document: Optional[int] = None label: Optional[str] = None text: Optional[str] = None class CreateClassificationResponse(BaseModel): completion: Optional[str] = None label: Optional[str] = None model: Optional[str] = None object: Optional[str] = None search_model: Optional[str] = None selected_examples: Optional[List[SelectedExample]] = None class PromptItem(RootModel[List[int]]): root: List[int] class CreateCompletionRequest(BaseModel): best_of: Optional[conint(ge=0, le=20)] = Field( 1, description='Generates `best_of` completions server-side and returns the "best" (the one with the highest log probability per token). Results cannot be streamed.\n\nWhen used with `n`, `best_of` controls the number of candidate completions and `n` specifies how many to return – `best_of` must be greater than `n`.\n\n**Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.\n', ) echo: Optional[bool] = Field( False, description='Echo back the prompt in addition to the completion\n' ) frequency_penalty: Optional[confloat(ge=-2.0, le=2.0)] = Field( 0, description="Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.\n\n[See more information about frequency and presence penalties.](/docs/api-reference/parameter-details)\n", ) logit_bias: Optional[Dict[str, Any]] = Field( None, description='Modify the likelihood of specified tokens appearing in the completion.\n\nAccepts a json object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this [tokenizer tool](/tokenizer?view=bpe) (which works for both GPT-2 and GPT-3) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.\n\nAs an example, you can pass `{"50256": -100}` to prevent the <|endoftext|> token from being generated.\n', ) logprobs: Optional[conint(ge=0, le=5)] = Field( None, description='Include the log probabilities on the `logprobs` most likely tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response.\n\nThe maximum value for `logprobs` is 5. If you need more than this, please contact us through our [Help center](https://help.openai.com) and describe your use case.\n', ) max_tokens: Optional[conint(ge=0)] = Field( 16, description="The maximum number of [tokens](/tokenizer) to generate in the completion.\n\nThe token count of your prompt plus `max_tokens` cannot exceed the model's context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096).\n", examples=[16], ) model: str = Field( ..., description='ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them.', ) n: Optional[conint(ge=1, le=128)] = Field( 1, description='How many completions to generate for each prompt.\n\n**Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.\n', examples=[1], ) presence_penalty: Optional[confloat(ge=-2.0, le=2.0)] = Field( 0, description="Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.\n\n[See more information about frequency and presence penalties.](/docs/api-reference/parameter-details)\n", ) prompt: Optional[Union[str, List[str], List[int], List[PromptItem]]] = Field( '<|endoftext|>', description='The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.\n\nNote that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document.\n', ) stop: Optional[Union[str, List[str]]] = Field( None, description='Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.\n', ) stream: Optional[bool] = Field( False, description='Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message.\n', ) suffix: Optional[str] = Field( None, description='The suffix that comes after a completion of inserted text.', examples=['test.'], ) temperature: Optional[confloat(ge=0.0, le=2.0)] = Field( 1, description='What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\n\nWe generally recommend altering this or `top_p` but not both.\n', examples=[1], ) top_p: Optional[confloat(ge=0.0, le=1.0)] = Field( 1, description='An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nWe generally recommend altering this or `temperature` but not both.\n', examples=[1], ) user: Optional[str] = Field( None, description='A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).\n', examples=['user-1234'], ) class Logprobs(BaseModel): text_offset: Optional[List[int]] = None token_logprobs: Optional[List[float]] = None tokens: Optional[List[str]] = None top_logprobs: Optional[List[Dict[str, Any]]] = None class Choice1(BaseModel): finish_reason: Optional[str] = None index: Optional[int] = None logprobs: Optional[Logprobs] = None text: Optional[str] = None class CreateCompletionResponse(BaseModel): choices: List[Choice1] created: int id: str model: str object: str usage: Optional[Usage] = None class CreateEditRequest(BaseModel): input: Optional[str] = Field( '', description='The input text to use as a starting point for the edit.', examples=['What day of the wek is it?'], ) instruction: str = Field( ..., description='The instruction that tells the model how to edit the prompt.', examples=['Fix the spelling mistakes.'], ) model: str = Field( ..., description='ID of the model to use. You can use the `text-davinci-edit-001` or `code-davinci-edit-001` model with this endpoint.', ) n: Optional[conint(ge=1, le=20)] = Field( 1, description='How many edits to generate for the input and instruction.', examples=[1], ) temperature: Optional[confloat(ge=0.0, le=2.0)] = Field( 1, description='What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.\n\nWe generally recommend altering this or `top_p` but not both.\n', examples=[1], ) top_p: Optional[confloat(ge=0.0, le=1.0)] = Field( 1, description='An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\nWe generally recommend altering this or `temperature` but not both.\n', examples=[1], ) class Choice2(BaseModel): finish_reason: Optional[str] = None index: Optional[int] = None logprobs: Optional[Logprobs] = None text: Optional[str] = None class CreateEditResponse(BaseModel): choices: List[Choice2] created: int object: str usage: Usage class InputItem(RootModel[List[int]]): root: List[int] class CreateEmbeddingRequest(BaseModel): model_config = ConfigDict( extra='forbid', ) input: Union[str, List[str], List[int], List[InputItem]] = Field( ..., description='Input text to get embeddings for, encoded as a string or array of tokens. To get embeddings for multiple inputs in a single request, pass an array of strings or array of token arrays. Each input must not exceed 8192 tokens in length.\n', examples=['The quick brown fox jumped over the lazy dog'], ) model: str = Field( ..., description='ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them.', ) user: Optional[str] = Field( None, description='A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).\n', examples=['user-1234'], ) class Datum(BaseModel): embedding: List[float] index: int object: str class Usage3(BaseModel): prompt_tokens: int total_tokens: int class CreateEmbeddingResponse(BaseModel): data: List[Datum] model: str object: str usage: Usage3 class CreateFileRequest(BaseModel): model_config = ConfigDict( extra='forbid', ) file: bytes_aliased = Field( ..., description='Name of the [JSON Lines](https://jsonlines.readthedocs.io/en/latest/) file to be uploaded.\n\nIf the `purpose` is set to "fine-tune", each line is a JSON record with "prompt" and "completion" fields representing your [training examples](/docs/guides/fine-tuning/prepare-training-data).\n', ) purpose: str = Field( ..., description='The intended purpose of the uploaded documents.\n\nUse "fine-tune" for [Fine-tuning](/docs/api-reference/fine-tunes). This allows us to validate the format of the uploaded file.\n', ) class CreateFineTuneRequest(BaseModel): batch_size: Optional[int] = Field( None, description="The batch size to use for training. The batch size is the number of\ntraining examples used to train a single forward and backward pass.\n\nBy default, the batch size will be dynamically configured to be\n~0.2% of the number of examples in the training set, capped at 256 -\nin general, we've found that larger batch sizes tend to work better\nfor larger datasets.\n", ) classification_betas: Optional[List[float]] = Field( None, description='If this is provided, we calculate F-beta scores at the specified\nbeta values. The F-beta score is a generalization of F-1 score.\nThis is only used for binary classification.\n\nWith a beta of 1 (i.e. the F-1 score), precision and recall are\ngiven the same weight. A larger beta score puts more weight on\nrecall and less on precision. A smaller beta score puts more weight\non precision and less on recall.\n', examples=[[0.6, 1, 1.5, 2]], ) classification_n_classes: Optional[int] = Field( None, description='The number of classes in a classification task.\n\nThis parameter is required for multiclass classification.\n', ) classification_positive_class: Optional[str] = Field( None, description='The positive class in binary classification.\n\nThis parameter is needed to generate precision, recall, and F1\nmetrics when doing binary classification.\n', ) compute_classification_metrics: Optional[bool] = Field( False, description='If set, we calculate classification-specific metrics such as accuracy\nand F-1 score using the validation set at the end of every epoch.\nThese metrics can be viewed in the [results file](/docs/guides/fine-tuning/analyzing-your-fine-tuned-model).\n\nIn order to compute classification metrics, you must provide a\n`validation_file`. Additionally, you must\nspecify `classification_n_classes` for multiclass classification or\n`classification_positive_class` for binary classification.\n', ) learning_rate_multiplier: Optional[float] = Field( None, description='The learning rate multiplier to use for training.\nThe fine-tuning learning rate is the original learning rate used for\npretraining multiplied by this value.\n\nBy default, the learning rate multiplier is the 0.05, 0.1, or 0.2\ndepending on final `batch_size` (larger learning rates tend to\nperform better with larger batch sizes). We recommend experimenting\nwith values in the range 0.02 to 0.2 to see what produces the best\nresults.\n', ) model: Optional[str] = Field( 'curie', description='The name of the base model to fine-tune. You can select one of "ada",\n"babbage", "curie", "davinci", or a fine-tuned model created after 2022-04-21.\nTo learn more about these models, see the\n[Models](https://platform.openai.com/docs/models) documentation.\n', ) n_epochs: Optional[int] = Field( 4, description='The number of epochs to train the model for. An epoch refers to one\nfull cycle through the training dataset.\n', ) prompt_loss_weight: Optional[float] = Field( 0.01, description='The weight to use for loss on the prompt tokens. This controls how\nmuch the model tries to learn to generate the prompt (as compared\nto the completion which always has a weight of 1.0), and can add\na stabilizing effect to training when completions are short.\n\nIf prompts are extremely long (relative to completions), it may make\nsense to reduce this weight so as to avoid over-prioritizing\nlearning the prompt.\n', ) suffix: Optional[constr(min_length=1, max_length=40)] = Field( None, description='A string of up to 40 characters that will be added to your fine-tuned model name.\n\nFor example, a `suffix` of "custom-model-name" would produce a model name like `ada:ft-your-org:custom-model-name-2022-02-15-04-21-04`.\n', ) training_file: str = Field( ..., description='The ID of an uploaded file that contains training data.\n\nSee [upload file](/docs/api-reference/files/upload) for how to upload a file.\n\nYour dataset must be formatted as a JSONL file, where each training\nexample is a JSON object with the keys "prompt" and "completion".\nAdditionally, you must upload your file with the purpose `fine-tune`.\n\nSee the [fine-tuning guide](/docs/guides/fine-tuning/creating-training-data) for more details.\n', examples=['file-ajSREls59WBbvgSzJSVWxMCB'], ) validation_file: Optional[str] = Field( None, description='The ID of an uploaded file that contains validation data.\n\nIf you provide this file, the data is used to generate validation\nmetrics periodically during fine-tuning. These metrics can be viewed in\nthe [fine-tuning results file](/docs/guides/fine-tuning/analyzing-your-fine-tuned-model).\nYour train and validation data should be mutually exclusive.\n\nYour dataset must be formatted as a JSONL file, where each validation\nexample is a JSON object with the keys "prompt" and "completion".\nAdditionally, you must upload your file with the purpose `fine-tune`.\n\nSee the [fine-tuning guide](/docs/guides/fine-tuning/creating-training-data) for more details.\n', examples=['file-XjSREls59WBbvgSzJSVWxMCa'], ) class ResponseFormat(Enum): url = 'url' b64_json = 'b64_json' class Size(Enum): field_256x256 = '256x256' field_512x512 = '512x512' field_1024x1024 = '1024x1024' class CreateImageEditRequest(BaseModel): image: bytes_aliased = Field( ..., description='The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.', ) mask: Optional[bytes_aliased] = Field( None, description='An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`.', ) n: Optional[conint(ge=1, le=10)] = Field( 1, description='The number of images to generate. Must be between 1 and 10.', examples=[1], ) prompt: str = Field( ..., description='A text description of the desired image(s). The maximum length is 1000 characters.', examples=['A cute baby sea otter wearing a beret'], ) response_format: Optional[ResponseFormat] = Field( 'url', description='The format in which the generated images are returned. Must be one of `url` or `b64_json`.', examples=['url'], ) size: Optional[Size] = Field( '1024x1024', description='The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.', examples=['1024x1024'], ) user: Optional[str] = Field( None, description='A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).\n', examples=['user-1234'], ) class CreateImageRequest(BaseModel): n: Optional[conint(ge=1, le=10)] = Field( 1, description='The number of images to generate. Must be between 1 and 10.', examples=[1], ) prompt: str = Field( ..., description='A text description of the desired image(s). The maximum length is 1000 characters.', examples=['A cute baby sea otter'], ) response_format: Optional[ResponseFormat] = Field( 'url', description='The format in which the generated images are returned. Must be one of `url` or `b64_json`.', examples=['url'], ) size: Optional[Size] = Field( '1024x1024', description='The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.', examples=['1024x1024'], ) user: Optional[str] = Field( None, description='A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).\n', examples=['user-1234'], ) class CreateImageVariationRequest(BaseModel): image: bytes_aliased = Field( ..., description='The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.', ) n: Optional[conint(ge=1, le=10)] = Field( 1, description='The number of images to generate. Must be between 1 and 10.', examples=[1], ) response_format: Optional[ResponseFormat] = Field( 'url', description='The format in which the generated images are returned. Must be one of `url` or `b64_json`.', examples=['url'], ) size: Optional[Size] = Field( '1024x1024', description='The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.', examples=['1024x1024'], ) user: Optional[str] = Field( None, description='A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).\n', examples=['user-1234'], ) class CreateModerationRequest(BaseModel): input: Union[str, List[str]] = Field(..., description='The input text to classify') model: Optional[str] = Field( 'text-moderation-latest', description='Two content moderations models are available: `text-moderation-stable` and `text-moderation-latest`.\n\nThe default is `text-moderation-latest` which will be automatically upgraded over time. This ensures you are always using our most accurate model. If you use `text-moderation-stable`, we will provide advanced notice before updating the model. Accuracy of `text-moderation-stable` may be slightly lower than for `text-moderation-latest`.\n', examples=['text-moderation-stable'], ) class Categories(BaseModel): hate: bool hate_threatening: bool = Field(..., alias='hate/threatening') self_harm: bool = Field(..., alias='self-harm') sexual: bool sexual_minors: bool = Field(..., alias='sexual/minors') violence: bool violence_graphic: bool = Field(..., alias='violence/graphic') class CategoryScores(BaseModel): hate: float hate_threatening: float = Field(..., alias='hate/threatening') self_harm: float = Field(..., alias='self-harm') sexual: float sexual_minors: float = Field(..., alias='sexual/minors') violence: float violence_graphic: float = Field(..., alias='violence/graphic') class Result(BaseModel): categories: Categories category_scores: CategoryScores flagged: bool class CreateModerationResponse(BaseModel): id: str model: str results: List[Result] class CreateSearchRequest(BaseModel): documents: Optional[List[str]] = Field( None, description='Up to 200 documents to search over, provided as a list of strings.\n\nThe maximum document length (in tokens) is 2034 minus the number of tokens in the query.\n\nYou should specify either `documents` or a `file`, but not both.\n', examples=["['White House', 'hospital', 'school']"], max_length=200, min_length=1, ) file: Optional[str] = Field( None, description='The ID of an uploaded file that contains documents to search over.\n\nYou should specify either `documents` or a `file`, but not both.\n', ) max_rerank: Optional[conint(ge=1)] = Field( 200, description='The maximum number of documents to be re-ranked and returned by search.\n\nThis flag only takes effect when `file` is set.\n', ) query: constr(min_length=1) = Field( ..., description='Query to search against the documents.', examples=['the president'], ) return_metadata: Optional[bool] = Field( False, description='A special boolean flag for showing metadata. If set to `true`, each document entry in the returned JSON will contain a "metadata" field.\n\nThis flag only takes effect when `file` is set.\n', ) user: Optional[str] = Field( None, description='A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids).\n', examples=['user-1234'], ) class Datum1(BaseModel): document: Optional[int] = None object: Optional[str] = None score: Optional[float] = None class CreateSearchResponse(BaseModel): data: Optional[List[Datum1]] = None model: Optional[str] = None object: Optional[str] = None class CreateTranscriptionRequest(BaseModel): model_config = ConfigDict( extra='forbid', ) file: bytes_aliased = Field( ..., description='The audio file to transcribe, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.\n', ) language: Optional[str] = Field( None, description='The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency.\n', ) model: str = Field( ..., description='ID of the model to use. Only `whisper-1` is currently available.\n', ) prompt: Optional[str] = Field( None, description="An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language.\n", ) response_format: Optional[str] = Field( 'json', description='The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.\n', ) temperature: Optional[float] = Field( 0, description='The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.\n', ) class CreateTranscriptionResponse(BaseModel): text: str class CreateTranslationRequest(BaseModel): model_config = ConfigDict( extra='forbid', ) file: bytes_aliased = Field( ..., description='The audio file to translate, in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.\n', ) model: str = Field( ..., description='ID of the model to use. Only `whisper-1` is currently available.\n', ) prompt: Optional[str] = Field( None, description="An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English.\n", ) response_format: Optional[str] = Field( 'json', description='The format of the transcript output, in one of these options: json, text, srt, verbose_json, or vtt.\n', ) temperature: Optional[float] = Field( 0, description='The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.\n', ) class CreateTranslationResponse(BaseModel): text: str class DeleteFileResponse(BaseModel): deleted: bool id: str object: str class DeleteModelResponse(BaseModel): deleted: bool id: str object: str class Engine(BaseModel): created: int id: str object: str ready: bool class FineTuneEvent(BaseModel): created_at: int level: str message: str object: str class Datum2(BaseModel): b64_json: Optional[str] = None url: Optional[str] = None class ImagesResponse(BaseModel): created: int data: List[Datum2] class ListEnginesResponse(BaseModel): data: List[Engine] object: str class ListFineTuneEventsResponse(BaseModel): data: List[FineTuneEvent] object: str class Model(BaseModel): created: int id: str object: str owned_by: str class OpenAIFile(BaseModel): bytes: int created_at: int filename: str id: str object: str purpose: str status: Optional[str] = None status_details: Optional[Dict[str, Any]] = None class FineTune(BaseModel): created_at: int events: Optional[List[FineTuneEvent]] = None fine_tuned_model: str hyperparams: Dict[str, Any] id: str model: str object: str organization_id: str result_files: List[OpenAIFile] status: str training_files: List[OpenAIFile] updated_at: int validation_files: List[OpenAIFile] class ListFilesResponse(BaseModel): data: List[OpenAIFile] object: str class ListFineTunesResponse(BaseModel): data: List[FineTune] object: str class ListModelsResponse(BaseModel): data: List[Model] object: str

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ag2-mcp-servers/openai-api'

If you have feedback or need assistance with the MCP directory API, please join our Discord server