LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coremessagesblock_translatorsopenaiconvert_to_openai_data_block
    Function●Since v1.0

    convert_to_openai_data_block

    Format standard data content block to format expected by OpenAI.

    "Standard data content block" can include old-style LangChain v0 blocks (URLContentBlock, Base64ContentBlock, IDContentBlock) or new ones.

    Copy
    convert_to_openai_data_block(
      block: dict,
      api: Literal['chat/completions', 'responses'] = 'chat/completions'
    ) -> dict

    Parameters

    NameTypeDescription
    block*dict

    The content block to convert.

    apiLiteral['chat/completions', 'responses']
    Default:'chat/completions'

    The OpenAI API being targeted. Either "chat/completions" or "responses".

    View source on GitHub