MCPcopy
hub / github.com/openai/openai-python / create

Method create

src/openai/resources/completions.py:619–774  ·  view source on GitHub ↗

Creates a completion for the provided prompt and parameters. Returns a completion object, or a sequence of completion objects if the request is streamed. Args: model: ID of the model to use. You can use the [List models](https://platform.ope

(
        self,
        *,
        model: Union[str, Literal["gpt-3.5-turbo-instruct", "davinci-002", "babbage-002"]],
        prompt: Union[str, SequenceNotStr[str], Iterable[int], Iterable[Iterable[int]], None],
        best_of: Optional[int] | Omit = omit,
        echo: Optional[bool] | Omit = omit,
        frequency_penalty: Optional[float] | Omit = omit,
        logit_bias: Optional[Dict[str, int]] | Omit = omit,
        logprobs: Optional[int] | Omit = omit,
        max_tokens: Optional[int] | Omit = omit,
        n: Optional[int] | Omit = omit,
        presence_penalty: Optional[float] | Omit = omit,
        seed: Optional[int] | Omit = omit,
        stop: Union[Optional[str], SequenceNotStr[str], None] | Omit = omit,
        stream: Optional[Literal[False]] | Omit = omit,
        stream_options: Optional[ChatCompletionStreamOptionsParam] | Omit = omit,
        suffix: Optional[str] | Omit = omit,
        temperature: Optional[float] | Omit = omit,
        top_p: Optional[float] | Omit = omit,
        user: str | Omit = omit,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    )

Source from the content-addressed store, hash-verified

617
618 @overload
619 async def create(
620 self,
621 *,
622 model: Union[str, Literal["gpt-3.5-turbo-instruct", "davinci-002", "babbage-002"]],
623 prompt: Union[str, SequenceNotStr[str], Iterable[int], Iterable[Iterable[int]], None],
624 best_of: Optional[int] | Omit = omit,
625 echo: Optional[bool] | Omit = omit,
626 frequency_penalty: Optional[float] | Omit = omit,
627 logit_bias: Optional[Dict[str, int]] | Omit = omit,
628 logprobs: Optional[int] | Omit = omit,
629 max_tokens: Optional[int] | Omit = omit,
630 n: Optional[int] | Omit = omit,
631 presence_penalty: Optional[float] | Omit = omit,
632 seed: Optional[int] | Omit = omit,
633 stop: Union[Optional[str], SequenceNotStr[str], None] | Omit = omit,
634 stream: Optional[Literal[False]] | Omit = omit,
635 stream_options: Optional[ChatCompletionStreamOptionsParam] | Omit = omit,
636 suffix: Optional[str] | Omit = omit,
637 temperature: Optional[float] | Omit = omit,
638 top_p: Optional[float] | Omit = omit,
639 user: str | Omit = omit,
640 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
641 # The extra values given here take precedence over values defined on the client or passed to this method.
642 extra_headers: Headers | None = None,
643 extra_query: Query | None = None,
644 extra_body: Body | None = None,
645 timeout: float | httpx.Timeout | None | NotGiven = not_given,
646 ) -> Completion:
647 """
648 Creates a completion for the provided prompt and parameters.
649
650 Returns a completion object, or a sequence of completion objects if the request
651 is streamed.
652
653 Args:
654 model: ID of the model to use. You can use the
655 [List models](https://platform.openai.com/docs/api-reference/models/list) API to
656 see all of your available models, or see our
657 [Model overview](https://platform.openai.com/docs/models) for descriptions of
658 them.
659
660 prompt: The prompt(s) to generate completions for, encoded as a string, array of
661 strings, array of tokens, or array of token arrays.
662
663 Note that <|endoftext|> is the document separator that the model sees during
664 training, so if a prompt is not specified the model will generate as if from the
665 beginning of a new document.
666
667 best_of: Generates `best_of` completions server-side and returns the "best" (the one with
668 the highest log probability per token). Results cannot be streamed.
669
670 When used with `n`, `best_of` controls the number of candidate completions and
671 `n` specifies how many to return – `best_of` must be greater than `n`.
672
673 **Note:** Because this parameter generates many completions, it can quickly
674 consume your token quota. Use carefully and ensure that you have reasonable
675 settings for `max_tokens` and `stop`.
676

Callers

nothing calls this directly

Calls 2

async_maybe_transformFunction · 0.85
make_request_optionsFunction · 0.85

Tested by

no test coverage detected